S
Seoffix.com
Sign In Get Pro Membership

JavaScript & TypeScript

JavaScript: Modern Async/Await & Fetch API

Beginner JavaScript 25 XP

JavaScript Async/Await & Fetch API

Modern JavaScript handles asynchronous operations with sync functions and the wait operator, making asynchronous code look and behave like synchronous code.

Syntax

async function loadData() {
  try {
    const res = await fetch(url);
    const data = await res.json();
    return data;
  } catch (err) {
    console.error(err);
  }
}

Your Task

Write an async function called calculateToolMetrics(tools) that filters tools with a rating of 4.5 or higher and returns their total count.

Hints

  1. Use the .filter() method on tools array
  2. Condition is t.rating >= 4.5
  3. Return .length of the filtered array

Live playground

Press Run to see the result.

AI Code Explainer & Translator

Runs without any outside service.
 
Mark Complete & Earn XP
Earn 25 XP. Finish every lesson in the track to earn its certificate.
Sign in to earn XP