forked from Ayaabuyousef/rbk-toy-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathW2D3.js
More file actions
45 lines (36 loc) · 1.57 KB
/
W2D3.js
File metadata and controls
45 lines (36 loc) · 1.57 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
//1- Write a function isTallEnough that takes a height (number) in inches,
//and returns true if the input is greater than or equal to 48, and false if it's less than 48 inches.
//Calling your function should result in:
function isTallEnough(num){
if (num >= 48){
return true
}return false
}
isTallEnough(72); //true
isTallEnough(28); //false
//2- Write a function isGoodFreethrowShooter that takes a shooting percentage
// (a number you can assume will be between 0 and 1 -- exclusive of 1).
//and returns based on the following criteria:
// If the number is between 0-0.65, return "Horrible freethrow shooter"
// If the number is between 0.65-0.80 return "Decent freethrow shooter"
// If the number is between 0.80-1.00 return "Great freethrow shooter"
// Each range is inclusive of the lower bound, and exclusive of the upper -- in other words,
//0.65 is counted as a "Decent freethrow shooter" (not "Horrible freethrow shooter")
//and 0.80 is considered a "Great freethrow shooter" (not "Decent freethrow shooter").
//Additionally, you can get a number as high as 0.99, but never 1
//(this is what the original problem statement means by "exclusive of 1").
// Calling your function should result in:
function isGoodFreethrowShooter(num){
if (num < 0.65){
return "Horrible freethrow shooter"
}
if(num < 0.8){
return "Decent freethrow shooter"
}
if (num <1){
return "Great freethrow shooter"
}
}
isGoodFreethrowShooter(0.90); //"Great freethrow shooter"
isGoodFreethrowShooter(0.09); //"Horrible freethrow shooter"
isGoodFreethrowShooter(0.75); //"Decent freethrow shooter"