-
Notifications
You must be signed in to change notification settings - Fork 14
/
Week-2.js
48 lines (31 loc) · 1.59 KB
/
Week-2.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
// 1. Write an anonymous function that takes one argument of type number and decides if that number is evenly divisble by three or not. If it is, print the number and "is divisible by three". If it is not, print that the number "is not divisble by three".
// 2. Write about yourself using an object. Include at least three properties of you and store your object in a variable with your name.
// 3. Given the object below, fill in how to find specific information:
var bicycle = {
type: "Roadbike",
gear: ["comfy seat", "cool handlebars", "vintage bell", "toe clips"],
wheels: {
count: 2,
specs: ["road tires", "AX-7563", "80-115 PSI"],
brand: "Trek"
}
}
// Log the type of bicycle:
console.log()
// Log just the bell from the list of gear
console.log()
// Log the correct PSI for the tires
console.log()
// 4. Have the function AlphabetSoup(str) take the "str" parameter being passed and return a string with the letters in alphabetical order (ie. hello becomes ehllo). Assume no numbers or punctuation symbols will not be included in the parameter.
// Input:"hooplah"
// Output:"ahhloop"
function AlphabetSoup(str) {
// your code goes here
return str;
}
// keep this function call here
AlphabetSoup(hooplah);
// 5. Given the arrays below, use a for loop to print one value from each array concatenated together. How would your code need to change to accomodate arrays of different lengths?
var nums = [1, 5, 88, 2, 5, 42, 57, 101]
var nouns = ["ducks", "telephone booth", "the enterprise", "robots", "amazon", "eraser", "zafod", "a"]
// output of the first function should be: "1 ducks"