-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathwarmUp7.js
37 lines (34 loc) · 985 Bytes
/
warmUp7.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
// 1-Choose the correct comparison operator to display "true", when: 5 is less than 7.
//answer :
function operator(num1,num2){
if (num1<num2){
return true ;
}
return false;
}
//2- Write a function named helloWorld that:
//takes 1 argument, a language code (e.g. "fr", "es", "en")
//returns "Hello, World" for the given language, for atleast 3 languages. It should default to returning English.
//ex: helloWorld('fr') ==> 'Bonjour tout le monde'
// helloWorld('es') ==> 'Hola, Mundo'
// helloWorld('') ==> 'Hello, World'
function helloWord(lang){
if(lang ==="fr"){
return "Bonjour tout le monde";
}else if (lang==="es"){
return"Hola,Mondo";
}else if (lang==="gr"){
return "Hallo an alle";
}else {
return "Good Morning";
}
}
//3- write a function to Reverse an array without use array.reverse() method:
// ex: reverseArray([1,2,3]) ==> [3,2,1]
function reverse(arr){
var myArr=[];
for (var i = arr.length-1 ; i>=0 ;i--){
myArr.push(arr[i]);
}
return myArr;
}