-
Notifications
You must be signed in to change notification settings - Fork 9
/
exercises.js
103 lines (56 loc) · 2.68 KB
/
exercises.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*Conditional statements gives us the ability to check conditions and change the behavior of the program accordingly:
if
else if
else
*/
//Invoke your functions and console.log your results
/*1. Create a function named isRainy which takes a boolean parameter boo.
This function will return the statement 'Bring an umbrella' if the boolean value is true.
*/
/*2. Create a function named vaccinated which takes a boolean parameter boo.
If the value is true, it'll return the statement: 'Please come in.'
If the value is false, it'll return the statement: 'Please show me your Covid test.'
*/
/*3. Create a function named scrabble which takes two string parameters word1, word2.
If word1 is longer than word2, it will return the statement: 'premium score'.
If not, it will return 'normal score'.
*/
/*4. Create a function named shopping which takes one number parameter budget.
If the budget is over 100, return 'Banana Republic';
If the budget is over 50, return 'Gap';
If the budget is 50 or less, return 'Old Navy';
*/
/*5. Create a function named bouncer which takes two number parameters, age, cover.
If the age is greater than or equal to 21 AND if the cover is greater than or equal to 10, return 'Please enter'
If not, return 'Sorry buddy'
*/
/*6. Create a function named even which takes a number parameter num.
If the number is even, it'll return true.
If not, it'll return false.
*/
//Loops allow you to do the same action(s) on every item in a list
//1. Create a for loop that will print number 0 - 10
//2. Create a for loop that will iterate and print each element in the array below.
let cookies = ['peanut butter', 'chocolate chip', 'almond', 'oreos', 'lemon'];
/*3. Create a for loop that will iterate each element in the array and print the following:
Player 0 is Tatum.
Player 1 is Hardaway.
Player 2 is Leonard.
Player 3 is Paul.
Player 4 is Webber.
Player 5 is Kidd.
*/
let players = ['Tatum', 'Hardaway', 'Leonard', 'Paul', 'Webber', 'Kidd'];
//4. Create a for loop that will push 20 odd numbers to the oddNum array. Start from 1.
let oddNum = [];
//5. Create a for loop that will push all even indexed rappers to the eastSide array and odd indexed rappers to the westSide array.
let rappers = ['DMX', 'Snoop', 'Jay-Z', 'Dre', 'Nas', 'Tupac', 'Biggie', 'Ice Cube', 'Ghostface Killah', 'Nipsey Hussle'];
let eastSide = [];
let westSide = [];
//6. Create a for loop that will sum up numbers from 1 to 100 and store the value in the sum variable.
let sum = 0;
/*7. Create a for loop that will print numbers from 0 to 60, but will print:
'Purple' if the number is divisible by 3
'Maia' if the number is divisible by 5
'Purple Maia' if the number is divisible by both 3 and 5
*/