Additional solution to Functional JS challenge (#29052)
* Added additional solution to the challenge * Moved code explanation out of code block * fix: moved sentences to same paragraph
This commit is contained in:
		
				
					committed by
					
						
						Randell Dawson
					
				
			
			
				
	
			
			
			
						parent
						
							362f3ad488
						
					
				
				
					commit
					4f71d9c8a7
				
			@@ -8,7 +8,28 @@ This challange is solved in 2 steps.
 | 
			
		||||
First, Array.prototype.filter is used to filter the array so it's left with elements that have imdbRating > 8.0. 
 | 
			
		||||
After that, Array.prototype.map can be used to shape the output to the desired format.
 | 
			
		||||
 | 
			
		||||
### Solution
 | 
			
		||||
### Beginner Solution
 | 
			
		||||
 | 
			
		||||
```javascript
 | 
			
		||||
 | 
			
		||||
// Add your code below this line
 | 
			
		||||
 | 
			
		||||
var filteredList = watchList.map((movie) => {
 | 
			
		||||
  return {
 | 
			
		||||
    title: movie.Title, 
 | 
			
		||||
    rating: movie.imdbRating
 | 
			
		||||
  }
 | 
			
		||||
}).filter((movie) => {
 | 
			
		||||
  // return true it will keep the item
 | 
			
		||||
  // return false it will reject the item
 | 
			
		||||
  return parseFloat(movie.rating) >= 8.0
 | 
			
		||||
});
 | 
			
		||||
```
 | 
			
		||||
#### Code Explanation
 | 
			
		||||
In the beginnner solution we're mapping over the watchList array to reduce the amount of data we have to work with and only returning the two items we need.  Once we've reduced the items to what we're interested in (Title and imdbRating) we're filtering through and only returning the remaining items that meet the criteria. In this case it's having an imdbRating of 8.0 or higher.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
### Intermediate Solution
 | 
			
		||||
 | 
			
		||||
```javascript
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user