I am learning to code and I am trying out this javascript object method course. I am currently stuck on this method. I want to have the array with three different numbers(2,5,10) to be /2. I do not understand why it is returning NaN. Thank you for reading.
//Eggs hatch time
eggHatchTime2km = 2
eggHatchTime5km = 5
eggHatchTime10km = 10
allEggsTime = [eggHatchTime2km,eggHatchTime5km,eggHatchTime10km];
console.log(allEggsTime); //reads out 2,5,10
const pokemonGoCommunityDay = {
eventBonuses: {
calculateEggHatchTime() {
return allEggsTime/2; //return NaN
//return eggHatchTime2km,eggHatchTime5km,eggHatchTime10km/2; //return the value of the last variable(10km) but not 2km and 5km
},
}
}
console.log(pokemonGoCommunityDay);
console.log(pokemonGoCommunityDay.eventBonuses.calculateEggHatchTime());