JavaScriptMediumData Structures

Parse and Extract from JSON

Write a function that takes a JSON string representing a list of users (each with name and email) and returns an array of just the email addresses.

Starter code

JavaScript
function extractEmails(jsonString) {
  // Your code here
}

// Test
const data = '[{"name":"Alice","email":"alice@example.com"},{"name":"Bob","email":"bob@example.com"}]';
console.log(extractEmails(data));  // ['alice@example.com', 'bob@example.com']

Stuck on this challenge?

Let CodeForge AI help you find the solution.