/javascript_arrays

Google x Udacity FEWD L15

Primary LanguageJavaScript

javascript_arrays

Q6-5: Consider the following array.

var team = ["Oliver Wood", "Angelina Johnson", "Katie Bell", "Alicia Spinnet", "George Weasley", "Fred Weasley", "Harry Potter"];

Create a function called hasEnoughPlayers() that takes the team array as an argument and returns true or false depending on if the array has at least seven players.

Q6-8: Use the array's forEach() method to loop over the following array and add 100 to each of the values if the value is divisible by 3.

var test = [12, 929, 11, 3, 199, 1000, 7, 1, 24, 37, 4, 19, 300, 3775, 299, 36, 209, 148, 169, 299, 6, 109, 20, 58, 139, 59, 3, 1, 139];

Q6-10: Use a nested for loop to take the numbers array below and replace all of the values that are divisible by 2 (even numbers) with the string "even" and all other numbers with the string "odd".

var numbers = [ [243, 12, 23, 12, 45, 45, 78, 66, 223, 3], [34, 2, 1, 553, 23, 4, 66, 23, 4, 55], [67, 56, 45, 553, 44, 55, 5, 428, 452, 3], [12, 31, 55, 445, 79, 44, 674, 224, 4, 21], [4, 2, 3, 52, 13, 51, 44, 1, 67, 5], [5, 65, 4, 5, 5, 6, 5, 43, 23, 4424], [74, 532, 6, 7, 35, 17, 89, 43, 43, 66], [53, 6, 89, 10, 23, 52, 111, 44, 109, 80], [67, 6, 53, 537, 2, 168, 16, 2, 1, 8], [76, 7, 9, 6, 3, 73, 77, 100, 56, 100] ];