Last active
September 20, 2018 21:18
-
-
Save tacyarg/8844495cbbf806566ec88deb5d1f447f to your computer and use it in GitHub Desktop.
examples of mapping using various methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeStudentsReport(data) { | |
const dataArray = []; | |
for(let e = 0; e < data.length; e++) { | |
const element = data[e]; | |
dataArray.push(`${element.name}: ${element.grade}`); | |
} | |
return dataArray; | |
} | |
function makeStudentsReport(data) { | |
var newState = [] | |
data.forEach(student => { | |
newState.push(`${student.name}: ${student.grade}`) | |
}) | |
return newState; | |
} | |
function makeStudentsReport(data) { | |
return data.map(student => { | |
return `${student.name}: ${student.grade}` | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment