forked from Ayaabuyousef/rbk-toy-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathW2D4.js
More file actions
47 lines (41 loc) · 1.28 KB
/
W2D4.js
File metadata and controls
47 lines (41 loc) · 1.28 KB
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
//1.Write a function called sameLength that takes two strings as parmeters,
//and returns true if those strings have the same length, and false otherwise.
function sameLength(str1,str2){
if (str1===str2){
return true
}return false
}
//2.Write a function called passwordLongEnough that takes a 'password' as a parameter
//and returns true if that password is long enough -- you get to decide what constitutes long enough.
function passwordLongEnough (password){
if (password.length === 8){
return true
}
return false
}
//3.Write a function called rentalCar that takes a person's name and age as parmeters,
//and returns either 'You cannot have the keys, .', or "Have fun driving",
// depending on whether or not the person is old enough.
//In the US, most rental car companies do not allow you to rent a car until you are 21.
function rentalCar (name,age){
if(age < 21){
returns 'You cannot have the keys'
}
return "Have fun driving"
}
// 4.Write a function called max that takes two numbers as parameters,
//and returns the larger one.
function max(num1,,num2){
if(num1 > num2){
return num1
}
return num2
}
// 5.Write a function called min that takes two numbers as parameters,
// and returns the smaller one.
function min (num1,num2){
if(num1 < num2){
return num1
}
return num2
}