Skip to content

Commit 931acfc

Browse files
committed
🔥 finish developer skills section
1 parent 2f3e514 commit 931acfc

File tree

5 files changed

+71
-10
lines changed

5 files changed

+71
-10
lines changed

03_Developers-Skills/challenge.js

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"use strict";
2+
3+
/* Given an array of forecasted maximum temperatures, the thermometer displays a string with these temperatures.
4+
5+
Example: [17, 21, 23] will print "...17°c in 1 days ...21°c in 2 days ...23°c in 3 days..."
6+
7+
Create a function 'printForecast' which takes in an array 'arr' and logs a string like the above to the console.
8+
9+
Use the problem-solving framework: Understand the problem and break it up into sub-problems!
10+
11+
? TEST DATA 1: [17, 21, 23]
12+
? TEST DATA 2: [12, 5, -5, 0, 4]
13+
*/
14+
15+
/*
16+
1. Understand the problem
17+
- What do you mean by maximum temperatures?
18+
All the temperatures in the array I guess.
19+
20+
- What happens if the thermometer forecasts a negative value?
21+
Go ahead and print it as required.
22+
23+
- Trailing dots before each value?
24+
- Does each array value signify a day?
25+
26+
2. Divide and conquer
27+
- Convert the numbers in the array to strings.
28+
- Concatenate the numbers with the degree symbol and the unit of celsius.
29+
- Loop through the values in the array and increase the day on each temperature by 1 day.
30+
- Log the value to the console.
31+
32+
3. Write sudo code
33+
Not required.
34+
*/
35+
36+
let arr = [17, 21, 23];
37+
const printForecast = function (arr) {
38+
for (let i = 0; i < arr.length; i++) {
39+
console.log(`...${arr[i]}°C in ${[i + 1]} days`);
40+
}
41+
};
42+
43+
arr = [12, 5, -5, 0, 4];
44+
printForecast(arr);
45+
46+
// JONAS Solution
47+
const data1 = [17, 21, 23];
48+
const data2 = [12, 5, -5, 0, 4];
49+
50+
console.log("___JONAS SOLUTION___");
51+
console.log(`...${data1[0]}°C ...${data1[1]}°C ...${data1[2]}°C ...`);
52+
53+
const printForecastJonas = function (arr) {
54+
let str = "";
55+
for (let i = 0; i < arr.length; i++) {
56+
str += `${arr[i]}°C in ${i + 1} days ...`;
57+
}
58+
console.log("..." + str);
59+
};
60+
61+
printForecastJonas(data1);

css/main.css

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/main.css.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>JavaScript Course</title>
54
<link rel="stylesheet" href="css/main.css" />
65
<link rel="favicon" href="favicon.ico" />
6+
<title>JavaScript Course</title>
77
</head>
88
<body>
9-
<h1>JavaScript Fundamentals Part 2</h1>
9+
<h1>Console.log()</h1>
10+
<script src="03_Developers-Skills/challenge.js"></script>
1011
</body>
11-
<script src="03_Developers-Skills/script.js"></script>
1212
</html>

sass/main.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
$bg-primary: linear-gradient(to top left, #28b487, #7dd56f);
2-
@import url(https://fonts.googleapis.com/css?family=Plus+Jakarta+Sans:200,300,regular,500,600,700,800,200italic,300italic,italic,500italic,600italic,700italic,800italic);
32

43
body {
54
height: 100vh;
65
display: flex;
76
align-items: center;
87
background: $bg-primary;
9-
font-family: "Plus Jakarta sans", sans-serif;
8+
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
109
overflow-y: hidden;
1110
}
1211
h1 {
13-
font-size: 50px;
12+
font-size: 35px;
1413
width: 100%;
1514
text-align: center;
1615
color: white;
16+
letter-spacing: -1px;
1717
}

0 commit comments

Comments
 (0)