// GUESS
function add (bookName) {
var newBookList = bookList;
return newBookList.push(bookName);
// Add your code above this line
}
// Add your code below this line
function remove (bookName) {
if (bookList.indexOf(bookName) >= 0) {
var newerBookList = bookList;
return newerBookList.splice(0, 1, bookName);
// Add your code above this line
}
}
// ACTUAL
function add (arr, bookName) {
let newArr = [...arr]; // Copy the bookList array to a new array.
newArr.push(bookName); // Add bookName parameter to the end of the new array.
return newArr; // Return the new array.
}
function remove (arr, bookName) {
let newArr = [...arr]; // Copy the bookList array to a new array.
if (newArr.indexOf(bookName) >= 0) { // Check whether the bookName parameter is in new array.
/.
newArr.splice(newArr.indexOf(bookName), 1); // Remove the given paramater from the new array.
return newArr; // Return the new array.
}
}
//GUESS
// Add your code below this line
function filteredList (watchList, greaterThan8) {
let newArray = [...watchList.filter(imdbRating => imdbRating >= 8)];
}
// ACTUAL
var filteredList = watchlist.map(function(e) {
return {title: e["Title"], rating: e["imdbRating"]}
}).filter((e) => e.rating >= 8);
//GUESS
var s = [23, 65, 98, 5];
Array.prototype.myFilter = function(callback){
var newArray = [];
s.forEach(function(element){
newArray.push(element < 90);
});
return newArray;
};
//ACTUAL
var s = [23, 65, 98, 5];
Array.prototype.myFilter = function(callback){
var newArray = [];
this.forEach(function(x) {
if (callback(x) == true) {
newArray.push(x);
}
return newArray;
};