[JavaScript] - Understanding JavaScript Functions and If | SheCodes

SheCodes Athena powered by AI

Your AI coding assistant, what do you need help with?

Ask a coding question

[JavaScript] - Understanding JavaScript Functions and If Statements

Learn how to create a travel function with JavaScript using prompt, if and else statement and alert.

πŸ‘©β€πŸ’» Code to be fixed

     function travel() {
        let name = prompt("What is your name?");
        let email = prompt("What is your email?");
        let travel = prompt("Do you enjoy traveling?");

        if (travel = "yes") {
        alert("Thank you " + name + "! I'll be in touch via email 😁");
      }
        else (travel !== "yes") 
        alert("Thank you" + name + "! we won't bother you with emails at the moment, but if you change your mind, let us know!");
        }

More coding questions about JavaScript

πŸ‘©β€πŸ’» Technical question

Asked 3 days ago in JavaScript by Meiramgul

How do you create a variable in Javascript?

πŸ‘©β€πŸ’» Technical question

what does the "return" do?

πŸ‘©β€πŸ’» Technical question

What is console.log

πŸ‘©β€πŸ’» Technical question

what are callback functions?

πŸ‘©β€πŸ’» Technical question

how to remove an item from an array

πŸ‘©β€πŸ’» Technical question

what does it mean to return something in javascript

πŸ‘©β€πŸ’» Technical question

Functions In Javascript

πŸ‘©β€πŸ’» Technical question

What is an arrow function and what is an example?

πŸ‘©β€πŸ’» Technical question

setInterval() explain this

πŸ‘©β€πŸ’» Technical question

what do the values "null" and undefined mean in js?

πŸ‘©β€πŸ’» Technical question

what is a parameter

πŸ‘©β€πŸ’» Technical question

How to remove items from an array in JS

πŸ‘©β€πŸ’» Technical question

what is the different between const and var and Iet in javascript

πŸ‘©β€πŸ’» Technical question

What is a ternary expression and what is an example?

πŸ‘©β€πŸ’» Technical question

Asked 9 days ago in JavaScript by Meiramgul

let vs var

πŸ‘©β€πŸ’» Technical question

how to add an extra property to an object

πŸ‘©β€πŸ’» Technical question

what is an api

πŸ‘©β€πŸ’» Technical question

what is the difference between argument and parameter?

πŸ‘©β€πŸ’» Technical question

What is nodejs

πŸ‘©β€πŸ’» Technical question

How to use push() in JavaScript

πŸ‘©β€πŸ’» Technical question

how to use assign()

πŸ‘©β€πŸ’» Technical question

how to console log

πŸ‘©β€πŸ’» Technical question

difference between let and const in javascript?

πŸ‘©β€πŸ’» Technical question

what is const

πŸ‘©β€πŸ’» Technical question

Remove Monday and Tuesday // Log the array

πŸ‘©β€πŸ’» Technical question

how to use template literals

πŸ‘©β€πŸ’» Technical question

remove element from array

πŸ‘©β€πŸ’» Technical question

How to set 2 conditions in a "if statement" in javascript?

πŸ‘©β€πŸ’» Technical question

Which JavaScript method converts JSON to a JavaScript value?

πŸ‘©β€πŸ’» Technical question

what is const?

πŸ‘©β€πŸ’» Technical question

how to use the math round method

πŸ‘©β€πŸ’» JavaScript Code instructions

let weather = { paris: { temp: 19.7, humidity: 80 }, tokyo: { temp: 17.3, humidity: 50 }, lisbon: { temp: 30.2, humidity: 20 }, "san francisco": { temp: 20.9, humidity: 100 }, oslo: { temp: -5, humidity: 20 } }; // write your code here let roundedWeather = {}; for (let city in weather) { roundedWeather[city] = {}; roundedWeather[city].temp = Math.ceil(weather[city].temp); roundedWeather[city].humidity = Math.ceil(weather[city].humidity); } console.log(roundedWeather); let city = prompt("Enter a city"); if (weather[city] !== undefined) { city = city.toLowerCase(); alert( `It is currently ${roundedWeather[city].temp}Β°C in ${city} with a humidity of ${roundedWeather[city].humidity}%` ); } else { alert( `Sorry we don't know the weather for this city, try going to https://www.google.com/search?q=weather+${[ city ]}` ); }

πŸ‘©β€πŸ’» Technical question

explain a JavaScript switch statment

πŸ‘©β€πŸ’» Technical question

What is package.json?

πŸ‘©β€πŸ’» Technical question

how do i add a new property to an existing object in javascript?

πŸ‘©β€πŸ’» Technical question

removing an item on array

πŸ‘©β€πŸ’» Technical question

what is a spread operator in javascript

πŸ‘©β€πŸ’» Technical question

what does eval() in JS mean

πŸ‘©β€πŸ’» Technical question

how to write a comment in java script

πŸ‘©β€πŸ’» Technical question

difference between == and ===

πŸ‘©β€πŸ’» Technical question

How do you map the array values without using map method

πŸ‘©β€πŸ’» Technical question

How can I make time in milliseconds to be updated in real time and in UTC

πŸ‘©β€πŸ’» Technical question

how to convert array to string using loops js

πŸ‘©β€πŸ’» Technical question

what is const in js

πŸ‘©β€πŸ’» Technical question

can you explain for in javascript, please

πŸ‘©β€πŸ’» Technical question

What is an if statement?

πŸ‘©β€πŸ’» Technical question

what is indexOf() in javascript

πŸ‘©β€πŸ’» Technical question

difference between for loop and map method