[JavaScript] - How to get rounded weather data for a city | SheCodes

[JavaScript] - How to get rounded weather data for a city in JavaScript

Learn how to retrieve and round weather data for a city using JavaScript, with prompts, alerts, and console.log statements.

πŸ‘©β€πŸ’» 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 ]}` ); }

More coding questions about JavaScript

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

Asked 1 day ago in JavaScript by Alejandra

how to get the input's value with a button

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

Write a for loop that prints every third number from 0 up to and including 99 using console.log

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

how to set counter

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

what is the time complexity of unshifting method

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

why am I receiving npm error 404 when trying to launch a new app?

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

What is variable hoisting in javascript?

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

how to get emojis

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

Asked 2 days ago in JavaScript by Boitumelo

Add a value attribute to both radio buttons. For convenience, set the button's value attribute to the same value as its id attribute.

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

Explain the difference between == and === in JavaScript

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

What does && mean in JavaScript

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

What is the .toLowerCase() function used for in JavaScript?

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

What is a variable in JavaScript?

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

what does an async function do?

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

how to use querySelectorAll ?

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

can you explain arrow functions?

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

what is null in js

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

.every() method in js

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

explain .reduce() method in js

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

how to round down using javascript

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

how to round up using javascript

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

What is the difference between undefined and null in JavaScript?

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

what is a console.log?

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

Can you explain JS functions return to me?

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

can you explain switch statements in javascript

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

How do I declare an array in JavaScript?

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

what is .join method in javascript

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

What is the purpose of using the let keyword in JavaScript?

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

what is the difference between let and const

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

What is a recursive function?

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

how do you get the system to ignore spaces in the response to a prompt question js

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

What character defines or gives access to jQuery?

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

how to comment on javascript

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

what is var in javescript?

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

what is a trim in javascript

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

What is a Template literal

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

How do you declare objects in JavaScript?

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

what is js math?

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

what is template literals?

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

what is the difference between == and ===? in javascript

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

what is "Identifier has already been declared" ?

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

When the button is clicked, replace button label by β€˜18 degrees’

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

how To display a phone number card when pressing an icon

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

what is cache expire date 10368000 ?

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

JavaScript functions

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

how to declare a function in javascript

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

what is the main use of filter method in js

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

How do I use backtick in javascript

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

what is hasOwnProperty in js

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

What is await in js

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

what is .toLowerCase()