JavaScript Functions and Conditional Statements:

JavaScript Functions and Conditional Statements: Full Detail (Part 3)

JavaScript Functions and Conditional Statements:


  1. Wow.., you’re a genius bro

  2. Done! Thanks as always for simplifying this👍🏽

  3. 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")

    1. Idowu Tolulope Great says:

      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.

    2. 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

  4. Meshack Stephen says:

    Thank you very much for all you do, my journey has been pleasant so far

  5. Can finally say I understand this after reading over and over again. Alhamdulilah. Thank you boss

Leave a Reply

Your email address will not be published. Required fields are marked *