-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathwarmUp3.js
34 lines (31 loc) · 1.15 KB
/
warmUp3.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
// 1 - Write functions larger and smaller that each accept two strings as arguments, and return the larger and smaller strings, respectively
function
// 2 - Write a function called counter that, when invoked, always returns a number that is one more than the previous invocation. For instance:
<<<<<<< HEAD
function counting(arr) {
// TODO: your code here
var result =0;
for (var i=0;arr[i]>arr.length;i++) {
result =arr[i];
}
return result;
}
// counting(5); // => '1, 2, 3, 4, 5'
// counting(1); // => '1'
// function counting(n) {
// TODO: your code here
// }
// counting(5); // => '1, 2, 3, 4, 5'
// counting(1); // => '1'
// counting(3); // => '1, 2, 3'
// 3 - Meet & Greet: n numbers are coming to a party for numbers. Introduce them each to all the guests as they arrive. You should end up with output looking something like this one for n = 5
// welcome 1
// welcome 2, meet 1
// welcome 3, meet 1 and 2
// welcome 4, meet 1, 2 and 3
// welcome 5, meet 1, 2, 3 and 4
//
function grreting(n){
return "welcom " + n + ', ' +"meet "+ (n-1) ;
}
// 4- Write a function shortestWord that works like longestWord, but returns the shortest word instead.