Update sort return
This commit is contained in:
		
							parent
							
								
									fecb114063
								
							
						
					
					
						commit
						6ade503338
					
				
					 1 changed files with 8 additions and 12 deletions
				
			
		
							
								
								
									
										20
									
								
								index.js
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								index.js
									
										
									
									
									
								
							|  | @ -10,7 +10,7 @@ async function sortHackerNewsArticles() { | |||
|   // go to Hacker News
 | ||||
|   await page.goto("https://news.ycombinator.com/newest"); | ||||
| 
 | ||||
|   // instantiate array for all date objects
 | ||||
|   // instantiate empty array for all date objects
 | ||||
|   let datestamps = []; | ||||
| 
 | ||||
|   // loop through process per page
 | ||||
|  | @ -31,18 +31,14 @@ async function sortHackerNewsArticles() { | |||
|   // drop extra array elements
 | ||||
|   datestamps.splice(100, 20); | ||||
| 
 | ||||
|   // check if the website dates are sorted and report results
 | ||||
|   if (datestamps === datestamps.sort()) { | ||||
|     console.log( | ||||
|       "Success! The first 100 articles are correctly sorted by posting time.", | ||||
|     ); | ||||
|   } else { | ||||
|     console.log( | ||||
|       "Failure… The first 100 articles are not correctly sorted by posting time.", | ||||
|     ); | ||||
|   } | ||||
|   // check if the website dates are sorted and return results
 | ||||
|   return datestamps === datestamps.sort(); | ||||
| } | ||||
| 
 | ||||
| (async () => { | ||||
|   await sortHackerNewsArticles(); | ||||
|   if (await sortHackerNewsArticles()) { | ||||
|     console.log("Success! The first 100 articles were sorted correctly."); | ||||
|   } else { | ||||
|     console.log("Failure… The first 100 articles were not sorted correctly."); | ||||
|   } | ||||
| })(); | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue