Answers for "Iterate an Array and make Object Key value pairs"

1

loop through key value pairs js

for (const [key, value] of Object.entries(object1)) {
  console.log(`${key}: ${value}`);
}
Posted by: Guest on May-30-2021
0

create pair foreach item in array

arr = [1, 2, 3, 4];

function pairwise(arr, func){
    for(var i=0; i < arr.length - 1; i++){
        func(arr[i], arr[i + 1])
    }
}

pairwise(arr, function(current, next){
    console.log(current, next)
})
Posted by: Guest on October-10-2020

Code answers related to "Iterate an Array and make Object Key value pairs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language