21 Day Coding Challenge

Challenge #5 - HELP (Error Persists)

#1

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

function findModuleIndex(moduleName) {
var modulecount = availableModules.length;
for(let i =0; i < modulecount; i++){
if((availableModules[i].name) == moduleName){
loadModule(i);
}
else
continue;
}
}

findModuleIndex(“propulsion”);
findModuleIndex(“life-support”);

Don’t know why this isn’t working!

1 Like
#2

In Challenge #5, the idea is that findModuleIndex() will return an index value, it won’t load/try to load the module, both functions becomes fully independent from one another.

2 Likes