-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmrs-morework.js
71 lines (68 loc) · 2.56 KB
/
mrs-morework.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
66
67
68
69
70
71
// // // (1)Write a function that takes in an array and returns a new array with all numbers multiplied by 3.
// // // Expected output --> [9, 27, 45, 12, 30]
//
// // var testArr1 = [3, 9, 15, 4, 10]
// // //created a function
// // const newArray = (array) => {
// // //new array to store multiplied numbers
// // let multiplied = []
// // //for loop that goes through every index of original array to multiply and pushes to new array
// // for (i = 0; i < array.length; i++){
// // multiplied.push(array[i] * 3)
// // }
// // //returns the multiplied array
// // return multiplied
// // }
// // console.log(newArray(testArr1));
// //(2) Write a function that takes in an array and returns a new array with only odd numbers.
// // Expected output --> [-7, 3, 5, 13]
// var testArr2 = [0, 2, -7, 3, 5, 8, 10, 13]
// //Declare our function and give it an argument
// const oddArray = (array) => {
// //Create our new array to hold the odd numbers
// let oddNums = [];
// //Create our loop to cycle through all elements in the array
// for (i=0 ; i < array.length ; i++) {
// //Setup a conditional that checks for odd numbers
// if (array[i] % 2 !== 0) {
// //Take odd numbers and add them to our new array
// oddNums.push(array[i]);
// }
// }
// //Return our new array of only odd numbers
// return oddNums;
// }
//
// // console.log(oddArray(testArr2));
//
// //(3) Write a function that takes in a string and returns a new string with every letter capitalized. HINT: you do not need arrays or loops.
// // Expected output --> "HELLO THERE"
// var myMessage = "Hello There"
//
// //Declare a function and an argument
// const upperCase = (string) => {
// //Use method to convert string to uppercase and store it in a variable
// let upper = string.toUpperCase();
// //Return uppercase string
// return upper;
// }
// console.log(upperCase(myMessage));
// (4) (INCOMPLETE) Write a function that takes in an array of numbers and letters and returns a string with only the letters. HINT: use the typeof method
// // Expected output --> "nicework"
var comboArr = [7, "n", true, "i", "c", 10, "e", -388, "w", 3, "o", 0, "r", false, "k"]
//create function and arguments
const compliment = (string) => {
//create a variable for new string
let compArray = []
// create a loop and nestle a conditional statement
for (i=0 ; i < string.length ; i++) {
//Setup a conditional statement that pulls the string
if (typeof string[i]===string) {
compArray.push(string[i])
//return the string using method .join
compArray.join("")
return compliment
}
}
}
console.log(typeof "i");