//1. Write a function that checks if the given input is an object.
After prompt number 1, you are given this :
function assert(expectedBehavior, descriptionOfCorrectBehavior) {
if (!expectedBehavior) {
console.log(descriptionOfCorrectBehavior);
} else {
console.log('test passed');
}
}
Study the function, and use it to test the function you just wrote for prompt number 1.
//2. Write another function that checks if the given input is an array. Utilize the previous function(s) written, and test your function.
Test your newly defined function.
//3. Study the format of the following data.
var allStars = [{
name: "Dwyane Wade",
pointsPerGame: 23.7,
assistsPerGame: 5.8,
reboundsPerGame: 4.8
}, {
name: "Kyle Lowry",
pointsPerGame: 13.5,
assistsPerGame: 5.7,
reboundsPerGame: 4.0
}, {
name: "LeBron James",
pointsPerGame: 27.2,
assistsPerGame: 6.9,
reboundsPerGame: 7.2
}, {
name: "Paul George",
pointsPerGame: 16.9,
assistsPerGame: 3.1,
reboundsPerGame: 6.2
}, {
name: "Carmelo Anthony",
pointsPerGame: 24.9,
assistsPerGame: 3.2,
reboundsPerGame: 6.6
}, {
name: "Stephen Curry",
pointsPerGame: 22.4,
assistsPerGame: 6.9,
reboundsPerGame: 4.3
}, {
name: "Russell Westbrook",
pointsPerGame: 21.5,
assistsPerGame: 2.6,
reboundsPerGame: 5.6
}, {
name: "Kobe Bryant",
pointsPerGame: 25.0,
assistsPerGame: 4.7,
reboundsPerGame: 5.2
}, {
name: "Kevin Durant",
pointsPerGame: 25.6,
assistsPerGame: 2.9,
reboundsPerGame: 5.6
}, {
name: "Kawhi Leonard",
pointsPerGame: 14.3,
assistsPerGame: 2.0,
reboundsPerGame: 6.3
}
]
//Your scouting manager only wants you to pay attention to players who score at least 20 points per game. Create a function that returns an array of player names who fit this description.
var highScoringPlayers = function(players){
}
//4. Right now your function looks for only players with 20 points per game. Modify your function such that it takes in a target number and filters accordingly.
E.g.
highScoringPlayers(allStars, 13); //returns a list of all-stars who get an average of at least 13 points per game.
//5. Modify your function to take in a third argument that indicates which property you are interested in, and returns a filtered array based on this.