forked from rezn5447/Coding-Practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6-19(2).js
More file actions
112 lines (66 loc) · 3.25 KB
/
6-19(2).js
File metadata and controls
112 lines (66 loc) · 3.25 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// You will be given a function in Javascript. All you have to do is rewrite it using ES6:
// PROBLEM #1 //
// Given this array of numbers:
numbers = [1,2,3]
// Your task is to return an array with all the numbers doubled and multiplied by
// their respective index in the array.
function doublesAndIndex(nums) {
return nums.map(function (number,index){
((number * 2 ) * index)
})
}
function doublesAndIndex(nums){
{
g {
// okay, block scoped name
const x = "sneaky";
// error, const
x = "foo";
}
// error, already declared in block
let x = "inner";
}
}
// Put es6 version here:
// PROBLEM #2 //
//Given the following lists:
var list1 = [
{ firstName: 'Roger', lastName: 'M.', country: 'Switzerland', continent: 'Europe', age: 19, language: 'JavaScript' },
{ firstName: 'Maia', lastName: 'S.', country: 'Tahiti', continent: 'Oceania', age: 28, language: 'JavaScript' },
{ firstName: 'Rupert', lastName: 'L.', country: 'Taiwan', continent: 'Asia', age: 35, language: 'HTML' },
{ firstName: 'Sumayah', lastName: 'M.', country: 'America', continent: 'Europe', age: 30, language: 'JavaScript' },
{ firstName: 'Sumayah', lastName: 'M.', country: 'Tajikistan', continent: 'Asia', age: 30, language: 'CSS' },
{ firstName: 'Richard', lastName: 'M.', country: 'America', continent: 'Europe', age: 30, language: 'JavaScript' },
{ firstName: 'Sumayah', lastName: 'M.', country: 'Europe', continent: 'Europe', age: 30, language: 'JavaScript' },
{ firstName: 'Rupaul', lastName: 'M.', country: 'Tajikistan', continent: 'Europe', age: 30, language: 'JavaScript' }
];
var list2 = [
{ firstName: 'Doger', lastName: 'M.', country: 'Switzerland', continent: 'Europe', age: 19, language: 'JavaScript' },
{ firstName: 'Maia', lastName: 'S.', country: 'Tahiti', continent: 'Oceania', age: 28, language: 'JavaScript' },
{ firstName: 'Lodash', lastName: 'L.', country: 'Taiwan', continent: 'Asia', age: 35, language: 'HTML' },
{ firstName: 'Sumayah', lastName: 'M.', country: 'America', continent: 'Europe', age: 30, language: 'JavaScript' },
{ firstName: 'Sumayah', lastName: 'M.', country: 'Tajikistan', continent: 'Asia', age: 30, language: 'CSS' },
{ firstName: 'Wichard', lastName: 'M.', country: 'America', continent: 'Europe', age: 30, language: 'JavaScript' },
{ firstName: 'Sumayah', lastName: 'M.', country: 'Europe', continent: 'Europe', age: 30, language: 'JavaScript' },
{ firstName: 'SpongeBob', lastName: 'M.', country: 'Tajikistan', continent: 'Europe', age: 30, language: 'JavaScript' }
];
// Your task is to return true if any of the JavaScript developers names start with R.
// Use .some and .includes
function includesR(list){
return list.some( function(dev) {
return dev.firstName.includes('R')
})
}
// Put es6 version here:
// PROBLEM #3 //
// Write a function that loops through the numbers n down to 0. Bonus points for recursion.
function looper(n){
var i = n
while(i >= 0){
console.log(i)
i--
}
return 'DONE!'
}
// Put es6 version here:
// Solutions will go here once we're all ready to see them: //