Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharks/Bahareh #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Sharks/Bahareh #17

wants to merge 2 commits into from

Conversation

b-izad
Copy link

@b-izad b-izad commented Jun 13, 2022

No description provided.

@b-izad b-izad changed the title everything finished other than real-time-temp Sharks/Bahareh Jun 13, 2022
Copy link

@spitsfire spitsfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, Bahareh! While these days we don't run into issues with JavaScript files loading faster than the html content can. That can make adding event handlers to HTML elements tricky.

It's standard practice to group all our event handlers and "register" them using the COMContentLoaded event at the end of the file. You may have seen function calls like this in the Learn platform:

const registerEventHandler = () => {
    realTimeButton.addEventListener('click', saveCity);
    // the rest of the event handlers here
};

document.addEventHandler('DOMContentLoaded', registerEventHandlers);

Comment on lines +34 to +47
.then((response) => {
console.log(response);
return response.data.current.temp;
})
.then((response)=>{
console.log(response);
return Math.floor((response - 273.15) * 9/5 + 32)
})
.then((response)=>{
console.log(response);
state.temp=response
tempContainer.textContent=`${state.temp}`;

})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooo nice job learning how to chain promises!

const saveCity=()=>{
const cityName= document.getElementById('input').value;
state.city=cityName
console.log(state.city);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to take out debugging print statements like this out for final submissions

Suggested change
console.log(state.city);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants