JPJayden Parkinjaydenjpark.hashnode.dev·Aug 18, 2022 · 1 min read[JavaScript] DOM - Find a DOM NodeHow would you implement getElementsByAttribute? HTML <!DOCTYPE html> <html> <head> <title>The DOM is cool</title> <script type="text/javascript" src="activity.js"></script> </head> <body> <h1 class="header">The DOM is cool for man...00
JPJayden Parkinjaydenjpark.hashnode.dev·Aug 18, 2022 · 1 min read[JavaScript] Asynchronous JavaScript: Promises, Async/Await, and AJAX - The Event Loop in Practiceconsole.log('Test start'); setTimeout(() => console.log('0 sec timer'), 0); Promise.resolve('Resolved promise 1').then(res => console.log(res)); Promise.resolve('Resolved promise 2').then(res => { for (let i = 0; i < 1000000000; i++) {} console....00
JPJayden Parkinjaydenjpark.hashnode.dev·Aug 17, 2022 · 2 min read[JavaScript] Asynchronous JavaScript: Promises, Async/Await, and AJAX - Coding Challenge #1In this challenge you will build a function 'whereAmI' which renders a country only based on GPS coordinates. For that, you will use a second API to geocode coordinates. So in this challenge, you’ll use an API on your own for the first time. Your tas...00
JPJayden Parkinjaydenjpark.hashnode.dev·Aug 16, 2022 · 1 min read[JavaScript] Asynchronous JavaScript: Promises, Async/Await, and AJAX - Throwing Error ManuallyCreating generic function const getJSON = function (url, errorMsg = 'Something went wrong') { return fetch(url).then(response => { if (!response.ok) throw new Error(`${errorMsg} (${response.status})`); return response.json(); }); }; Thro...00
JPJayden Parkinjaydenjpark.hashnode.dev·Aug 15, 2022 · 2 min read[JavaScript] Asynchronous JavaScript: Promises, Async/Await, and AJAX - Handling Rejected PromisesFirst example of catching error const getCountryData = function (country) { // country 1 fetch(`https://restcountries.com/v2/name/${country}`) .then( response => response.json() err => alert(err) // catching error (chain stop her...00