151
rated 0 times
[
158]
[
7]
/ answers: 1 / hits: 19015
/ 4 Years ago, tue, october 6, 2020, 12:00:00
how can I push keys and values in an empty object?
You are provided with an array, possibleIterable. Using a for loop, build out the object divByThree so that each key is an element of possibleIterable that is divisible by three. The value of each key should be the array index at which that key can be found in possibleIterable.
const possibleIterable = [4, 3, 9, 6, 23];
const divByThree = {};
// ADD CODE HERE
for (let i =0 ; i < possibleIterable.length; i++)
{
if (possibleIterable[i] % 3 === 0)
{
// ADD CODE HERE!
}
}
console.log(divByThree)
More From » arrays