JavaScript Functions and Conditional Statements: Full Detail (Part 3)
JavaScript Functions and Conditional Statements:
Congratulations, you are seeing this tweet. JavaScript will make you rich this year with another life-changing opportunity to transition into tech. On a:
Course: HTML, CSS & JAVASCRIPT
Title: JavaScript 3I’ll teach you like babies😉. Kindly retweet for other students, & open.
— Àgbà Akin (@Kynsofficial) January 24, 2022
Wow.., you’re a genius bro
Done! Thanks as always for simplifying this👍🏽
Good but my question goes to that last example, are those weather values meant for each conditional statement? Like weather(20) for if(temperature <= 30) {
console.log("It's freezing outside")
No, the values are different inputs for the temperature value in our weather function.
So each inputs will run through the code from top to bottom, and trigger the execution of the else if statement it returns a boolean value of True for.
If it returns false for all else if code block, it will automatically run the last code block which is the Else statement and give an output.
No,
weather(20) just means it will replace temperature with 20, like this;
var weather = function(20){
console.log(“The temperature outside is”, 20, “degrees farenheight.”);
if(20 <= 30) {
console.log("It's freezing outside! It'll be best to bundle up.");
} else if(20 <= 55) {
console.log("It's getting cold outside. Better wear a jacket!");
} else if (20 <= 75){
console.log("It's pleasant outside!");
} else {
console.log("It's getting hot outside!");
}
}
Same for 40, 60 etc.
So you will get 4 logs in your console that way
Thank you very much for all you do, my journey has been pleasant so far
Can finally say I understand this after reading over and over again. Alhamdulilah. Thank you boss
Thanks
Thanks boss,
May you remain blessed till eternity. Aameen