'Using the data retrieved, create an array using the map method to return just the title of every item and print the result in the console

Using the data retrieved, create an array using the map method to return just the title of every item and print the result in the console.

Code:

fetch('https://jsonplaceholder.typicode.com/todos').then(response => response.json()).then(data => {console.log(data)})

fetch('https://jsonplaceholder.typicode.com/todos').then(response => response.json()).then(data => {console.log(data)}) Using the data retrieved, create an array using the map method to return just the title of every item and print the result in the console.



Solution 1:[1]

fetch('https://jsonplaceholder.typicode.com/todos').then(response => response.json()).then(data => {
   data.map((elem) => {
    return elem.title 
  })
})

You store the result (of data.map) in whatever variable you like (it returns an array) Basically just returning the title of the object using Map().

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 aymcg31