Skip to content

Commit 6286abf

Browse files
committed
solution added
1 parent 216321f commit 6286abf

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

solutions/javascript-test-2020.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@ const multiplicationTable = n => {
1818
console.log(`${i} * ${i} = ${i * i}`)
1919
}
2020
}
21+
2122
multiplicationTable(11)
2223
console.log('----------------------------------------------------------- ')
2324

25+
// 1. 3
2426
const exponentialTable = () => {
2527
console.log(`i\ti^2\t^3`)
2628
for (let i = 0; i < 11; i++) {
2729
console.log(`${i}\t${i ** 2}\t${i ** 3}`)
2830
}
2931
}
32+
3033
exponentialTable()
3134
console.log('----------------------------------------------------------- ')
3235

33-
// 1. 3
36+
// 1. 4
3437
const countries = [
3538
'ALBANIA',
3639
'BOLIVIA',
@@ -81,6 +84,7 @@ const printProductItems = arr => {
8184
console.log(`The price of ${product} is ${formattedPrice}`)
8285
}
8386
}
87+
8488
printProductItems(products)
8589
console.log('----------------------------------------------------------- ')
8690

@@ -94,11 +98,10 @@ const sumOfAllPrices = arr => {
9498
}
9599
return total
96100
}
97-
console.log(
98-
'the sum of all the prices using for, for of, or forEach ',
99-
sumOfAllPrices(products)
100-
)
101+
102+
console.log('the sum of all prices using for of', sumOfAllPrices(products))
101103
console.log('----------------------------------------------------------- ')
104+
102105
// 2. 3
103106
const total = products
104107
.map(prod => prod.price)
@@ -115,7 +118,6 @@ const totalUsingReduce = products.reduce((accu, curr) => {
115118
}, 0)
116119

117120
console.log('reduce total', totalUsingReduce)
118-
119121
console.log(sumOfAllPrices(products))
120122
console.log('==================== END Q2 ============================ ')
121123

@@ -157,8 +159,8 @@ const howManyDaysInMonth = () => {
157159
}
158160
return statement
159161
}
160-
console.log(howManyDaysInMonth())
161162

163+
console.log(howManyDaysInMonth())
162164
console.log('----------------------------------------------------------- ')
163165

164166
// 3. 2
@@ -203,14 +205,15 @@ const generate = (type = 'id') => {
203205
return 'Not a valid format'
204206
}
205207
}
208+
206209
console.log(generate())
207210
console.log(generate('id'))
208211
console.log(generate('hexa'))
209212
console.log(generate('hexadecimal'))
210213
console.log(generate('rgb'))
211214
console.log(generate('RGB'))
212-
213215
console.log(generate('rgb'))
216+
214217
console.log('==================== END Q3 ============================ ')
215218

216219
console.log('==================== BEGIN Q4 ============================ ')
@@ -235,7 +238,6 @@ const countries2 = [
235238
const c = ['ESTONIA', 'FRANCE', 'GHANA']
236239
countries2.splice(4, 3, ...c)
237240
console.log(countries2)
238-
239241
console.log('----------------------------------------------------------- ')
240242

241243
// 4. 2
@@ -251,7 +253,6 @@ const arrOne = [1, 4, 6, 2, 1]
251253
console.log(checkUniqueness(arrOne)) // false
252254
const arrTwo = [1, 4, 6, 2, 3]
253255
console.log(checkUniqueness(arrTwo)) // true
254-
255256
console.log('----------------------------------------------------------- ')
256257

257258
// 4. 3
@@ -284,7 +285,6 @@ console.log(frontEnd, backEnd)
284285
console.log('----------------------------------------------------------- ')
285286

286287
// 5. 2
287-
// const [[h, css, j, r] = f, [n, e, m] = b] = fullStack
288288
const student = ['David', ['HTM', 'CSS', 'JS', 'React'], [98, 85, 90, 95]]
289289
const [
290290
name,
@@ -303,6 +303,7 @@ console.log(
303303
reactScore
304304
)
305305
console.log('----------------------------------------------------------- ')
306+
306307
// 5. 3
307308
const students = [
308309
['David', ['HTM', 'CSS', 'JS', 'React'], [98, 85, 90, 95]],
@@ -586,7 +587,6 @@ const numberOfLanguages = async () => {
586587
'Total number of langauges in the countries API:',
587588
Array.from(langSet).length
588589
)
589-
590590
console.log('----------------------------------------------------------- ')
591591
}
592592
numberOfLanguages()
@@ -626,7 +626,7 @@ const mostSpokenLanguages = async (n = 10) => {
626626

627627
console.log('Most spoken languages', mostSpokenLanguages(15))
628628

629-
console.log('----------------------------------------------------------- ')
629+
630630
// 8.2
631631

632632
const add = (a, b) => {

0 commit comments

Comments
 (0)