How do I display low and high temperature using Math.random in this code? (Javascript

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter4: The Selection Structure
Section: Chapter Questions
Problem 7E
icon
Related questions
Question
How do I display low and high temperature using Math.random in this code? (Javascript)
d View Navigate Debug Help
js
js
tm
1
// display Vancouver date and time
var vancTime = getDateByOffset(-8);
2
3 var elem = document.getElementById("vancTime");
4
elem.innerHTML = vancTime;
// display the forecast
var elem =
displayForecast (elem, vancTime);
6
7
9
10
11
12
13
14
21
24
22
**
15
16
..
17
// display the forecast
20
18 elem = document.getElementById("tor Forecast");
19 displayForecast (elem, torTime);
20
23
20
24
(Assign 5 Working) - Brackets
38
39
40
document.getElementById("vancForecast");
// display Toronto date and time
var torTime = getDateByOffset(-6);
elem = document.getElementById("tor Time");
elem.innerHTML = torTime;
25 // display the forecast
26
var elem = document.getElementById("winForecast");
27 displayForecast (elem, winTime);
28
20
29
30 ▼ /*
31
32
22
var winTime = getDateByoffset(-7);
var elem = document.getElementById("winTime");
elem.innerHTML = winTime;
33
34 function displayForecast (divElem, currentDate)
35 ▼ {
36
37 ▼
41
42 }
43
61
62
Create a new Date object for each of the 5 forecasts, then extract the day of the
week and display it. You can change the number of forecasts to whatever suits your
needs.
*/
57▼ {
58
59 }
60
for (var i= 1; i <= 3; i++)
{
44 ▼ /*
45
Return a low temperature using the Math.random method.
46 */
47
48 function getLowTemp()
49▼
var forecast = getDateForForecast (currentDate, i);
dayOfWeek
forecast.getDay();
divElem.innerHTML = weekdays [dayOfWeek] + ":" + getLowTemp() + getHighTemp()
+ "<br>";
}
50
51
52
53 ▼ /*
54
Return a high temperature using the Math.random method.
55 */
56 function getHighTemp()
return "<span style='margin-left: 15px'>Low e&deg; C </span>";
I
return "<span style='margin-left: 25px'>High e&deg; C </span>";
Transcribed Image Text:d View Navigate Debug Help js js tm 1 // display Vancouver date and time var vancTime = getDateByOffset(-8); 2 3 var elem = document.getElementById("vancTime"); 4 elem.innerHTML = vancTime; // display the forecast var elem = displayForecast (elem, vancTime); 6 7 9 10 11 12 13 14 21 24 22 ** 15 16 .. 17 // display the forecast 20 18 elem = document.getElementById("tor Forecast"); 19 displayForecast (elem, torTime); 20 23 20 24 (Assign 5 Working) - Brackets 38 39 40 document.getElementById("vancForecast"); // display Toronto date and time var torTime = getDateByOffset(-6); elem = document.getElementById("tor Time"); elem.innerHTML = torTime; 25 // display the forecast 26 var elem = document.getElementById("winForecast"); 27 displayForecast (elem, winTime); 28 20 29 30 ▼ /* 31 32 22 var winTime = getDateByoffset(-7); var elem = document.getElementById("winTime"); elem.innerHTML = winTime; 33 34 function displayForecast (divElem, currentDate) 35 ▼ { 36 37 ▼ 41 42 } 43 61 62 Create a new Date object for each of the 5 forecasts, then extract the day of the week and display it. You can change the number of forecasts to whatever suits your needs. */ 57▼ { 58 59 } 60 for (var i= 1; i <= 3; i++) { 44 ▼ /* 45 Return a low temperature using the Math.random method. 46 */ 47 48 function getLowTemp() 49▼ var forecast = getDateForForecast (currentDate, i); dayOfWeek forecast.getDay(); divElem.innerHTML = weekdays [dayOfWeek] + ":" + getLowTemp() + getHighTemp() + "<br>"; } 50 51 52 53 ▼ /* 54 Return a high temperature using the Math.random method. 55 */ 56 function getHighTemp() return "<span style='margin-left: 15px'>Low e&deg; C </span>"; I return "<span style='margin-left: 25px'>High e&deg; C </span>";
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Function Calling
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L