21 Day Coding Challenge

Little bit behind, need help on challenge 4

#1

function powerOn () {
ship.powerOn = true;
}
countModules = function(){
return availableModules.length
}

function countEssential(){
var count = 0;
for (var i = 0; i <availableModules.length; i++){
if (availableModules[i].essential){
count++;
}

}
return(count);
}

function loadModule (index) {
if (availableModules[index].essential !== true){
return null
} else {
availableModules[index].enabled = true;
ship.modules.push(availableModules[index])
}
}

function loopModule(){
for (let i = 0; i < availableModules.length; i++){
if (availableModules[i].name === ‘life-support’){
loadModule[i]
}
}
}
loopModule();

Confused as to why this isnt working for challenge 4. Would really appreciate some help.

#2

Hi Jonathan,
Do you happen to have the error message? Is it the one about the code running but not producing the proper results?

#3

My error message is as follows : Your code ran but did not produce the correct result. Hint: confirm your functions are properly solving the challenge.

Thanks for the swift response.

#4

If I told you that this line is the culprit, would you see why? (I can say more)

#5

DANG. Thanks a lot man.

1 Like
#6

Let us know if it works. But it’s the only thing I saw that didn’t work on my end.

#7

It worked, thanks so much. Cant believe i missed it

1 Like