-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
65 lines (55 loc) · 1.99 KB
/
main.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
//=============================================== 1
//Write a function called percentOf that takes two parameters,
//The function should find out what percentage the first number represents of the second number,
//and returns the result as a string.
//percentOf(5, 10) ==> "5 is 50% of 10"
//percentOf(2, 10) ==> "2 is 20% of 10"
// Note: please write one or two lines here describing your solution.
function percentOf(num1, num2) {
// TODO: your code here
}
//=============================================== 2
//Write a function called pluralize that:
//takes 2 parameters, a noun and a number.
//returns the number with the noun in pluralized form.
//pluralize('cat', 0) ==> "0 cats"
//pluralize('cat', 5) ==> "5 cats"
//pluralize('cat', 1) ==> "1 cat"
// Note: please write one or two lines here describing your solution.
function pluralize(noun, number) {
// TODO: your code here
}
//=============================================== 3
// write a function called addOne that takes an array of numbers as an input,
// and returns a new array with all array elements incremented by one as an output
// Note : solve this question using while loop
// addOne( [1,2,3,4] ) ==> [2,3,4,5]
// addOne( [3,6,9] ) ==> [4,7,10]
// Note: please write one or two lines here describing your solution.
function addOne(array) {
// TODO: your code here
}
//=============================================== 4
/*
Write a function that uses console.log to give the following triangle:
#
##
###
####
#####
######
#######
*/
// Note: please write one or two lines here describing your solution.
function drawTriangle() {
// TODO: your code here
}
//=============================================== 5
//Using recursion, Write a function that accepts a string and returns the number of vowels in that string.
//Note:Five of the 26 alphabet letters are vowels: A, E, I, O, and U.
//countVowels("four score and seven years") ==> 9;
//countVowels("rbk") ==> 0
function countVowels(string) {
// TODO: your code here
}
//Good Luck :))