Skip to content

Instantly share code, notes, and snippets.

@bethropolis
Last active December 7, 2024 20:28
Show Gist options
  • Save bethropolis/02e3471b6446f1a434d5dfe88814faae to your computer and use it in GitHub Desktop.
Save bethropolis/02e3471b6446f1a434d5dfe88814faae to your computer and use it in GitHub Desktop.
js arrays example
let arr = [1,2,3, 4,5,6,7,8]
let fruits = ["Apple", "Orange", "Pear"];
// 0 1 2
// loop
let doubled_result = arr.map(function(item){
return item * 2;
})
let fruits_object = fruits.map((fruit, index)=>{
return {
no: index + 1,
name: fruit,
}
})
console.log(doubled_result)
console.log(fruits_object)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment