forked from AdamMomen/warmUp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarmUp3.js
More file actions
42 lines (37 loc) · 1009 Bytes
/
Copy pathwarmUp3.js
File metadata and controls
42 lines (37 loc) · 1009 Bytes
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
// 1-Create arrays in the global scope consisting of strings that represent:
// -name of females in your class
// -name of males in your class
// -name of your class instructors
[fouz, ons, insaf, rouba];
[mehdi, essam, malik, ali, hashem, dhia];
[matt, saif, yousef];
// 2-write a function that takes an array as an argument and returns the element that is located in the middle of that array.
function warmUp3_2(arr){
var newArr = [];
var x = 0;
if (arr.length % 2 === 0) {
newArr.push("there is no middle element")
}
else if (arr.length % 2 === 1){
}
return newArr
}
<<<<<<< HEAD
// 3-Change all the numbers in the array to be multiplied by two for even indexes.
function warmUp3_3(arr){
var newArr = [];
var x = 0;
while(x<arr.length){
if (x % 2===0){
newArr.push(arr[x] * 2)
}
else {
newArr.push(arr[x])
}
x++
}
return newArr
}
=======
// 3-Change all the numbers in the array to be multiplied by two for even indexes.
>>>>>>> 53bc200a820913843d17cdb55e2d8c895974ce20