-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6.js
More file actions
30 lines (23 loc) · 851 Bytes
/
6.js
File metadata and controls
30 lines (23 loc) · 851 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
// Developer Skills & Editor Setup
// Coding Challenge #1
// Given an array of forecasted maximum temperatures, the thermometer displays a
// string with the given temperatures. Example: [17, 21, 23] will print "... 17ºC in 1
// days ... 21ºC in 2 days ... 23ºC in 3 days ..."
// Your tasks:
// 1. Create a function 'printForecast' which takes in an array 'arr' and logs a
// string like the above to the console. Try it with both test datasets.
// 2. Use the problem-solving framework: Understand the problem and break it up
// into sub-problems!
// Test data:
let arr1 = [17, 21, 23]
let arr2 = [12, 5, -5, 0, 4]
// // GOOD LUCK 😀
const printForecast = function (arr) {
let counter = 1;
for (let element of arr ) {
console.log(`... ${element}ºC in ${counter} days...`)
counter ++;
}
}
printForecast(arr1);
printForecast(arr2);