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

NW6| BakhatBegum | Module-JS3 | Feature/humor |Sprint-3 #300

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

Conversation

BakhatBegum
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

Copy link

Quality Gate Passed Quality Gate passed

Issues
1 New issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@BakhatBegum BakhatBegum changed the title NW6| BakhatBegum | Module-JS3 | Feature/xkcd |Sprint-3 NW6| BakhatBegum | Module-JS3 | Feature/humor |Sprint-3 Feb 17, 2024
Copy link
Member

@JayMayer JayMayer left a comment

Choose a reason for hiding this comment

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

Great work, Bakhat, your app works wonderfully! 🚀

I've left a few comments for you to check out, reach out on Slack if you have any questions.

Also be careful of your branches, to make sure that other exercises aren't accidentally included in the PR (I can see the book-library/ directory has come in to this PR).

}
});
}
getImageFetch();
Copy link
Member

Choose a reason for hiding this comment

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

Because we call getImageFetch() from inside the displayData() function, we don't need to call it here 🙂

}
const image = data.img;

const createImage = document.createElement('img');
Copy link
Member

Choose a reason for hiding this comment

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

I really like how you create the image element inside JavaScript! It means the user doesn't see a 'broken image' when they first load the page, creating a nice user experience

if(!data){
console.log("data can not found");
}
const image = data.img;
Copy link
Member

Choose a reason for hiding this comment

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

Could this variable name be a bit more descriptive? For example, imageUrl would make it clear that this is the link to the image

}
displayData();

window.onload = displayData;
Copy link
Member

Choose a reason for hiding this comment

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

When I launch the page, I see the same image appear twice. Having a look at these final lines of the JavaScript file, can you think why that might be?

function getImageFetch(){
return fetch('https://xkcd.now.sh/?comic=latest').then((response) => {
if(!response.ok){
return "Error";
Copy link
Member

Choose a reason for hiding this comment

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

Instead of just returning the text "Error", we could instead throw an exception. This is a large topic to cover here, so reach out on Slack if you have any questions on what this means!

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