Explaining fetch and promise to a 10 year old

code reviews programming

JavaScript is a computer language that helps make websites work. One of the things it can do is help a website get information from other websites. This is where "fetch method" comes in.

Fetch method is kind of like sending a message to another website asking for information. The other website sends back the information and your website displays it. It's kind of like asking your friend to get you a candy bar from the store and bring it back to you.

Now, sometimes it takes a little while for the other website to send back the information. This is where "promises" come in. Think of it like your friend saying "I promise to get you that candy bar and bring it back to you as soon as I can." So even if it takes a little while for your friend to get back to you, you know that they will eventually and it's worth the wait.

So, when a website uses fetch method with promises, it's like sending a message to another website and knowing that the website will eventually send back the information your website needs. It just might take a little while, but that's okay because you have a promise!

In summary, fetch method is like sending a message to another website and promises are like a friend promising to bring you back something. JavaScript can use these things to make websites work better and get information from other websites.