First time on CodeCombat and extremely new to programming in any language and wanted to see what the code would look like for this campaign level if an array was defined. Could an array of all of the ‘human’ names be created and then cross referenced in the if statement against the current prisoner name?
Sorry if this has already been addressed in a different area but I looked for the answer in other online resources and came up with nothing. Thanks for any clarification provided.
return 'Marcus William OtherName NameN'.indexOf(name)!=-1;
The optimal performance way:
if(!this.names){
//create a hashmap once
this.names = {
Marcus:true,
William: true,
OtherName:true,
NameN: true
}
}
//see if there is a key in our hashmap
return this.names[name];
By the way, it seems that this level (or the system itself) contains a bug. The ogre with ’ in his name says that he is “MARCUS” !
Your problems are all caused by case-sensitivity. In this case, True and False are capitalized when they shouldn’t be, and “Marcus” should be “MARCUS”.