javascript map number code example
Example 1: javascript map
function listFruits() {
let fruits = ["apple", "cherry", "pear"]
fruits.map((fruit, index) => {
console.log(index, fruit)
})
}
listFruits()
Example 2: javascript map array
const sweetArray = [2, 3, 4, 5, 35]
const sweeterArray = sweetArray.map(sweetItem => {
return sweetItem * 2
})
console.log(sweeterArray)
Example 3: javascript map
array.map( item => item.id )
array2.map( item => item.toString() )
array2.map( item => item * 3 )
Example 4: map method
var yourArray= yourArray.map(Number);