Hello fellow programmers :D
I have a little issue, this is a prep for an upcoming test, I have a wizard named Gorrok and I want him to cast a spell with the getSpell function, and I want it to be a random spell from the array I made called spells, I implemented the math.random method, for some reason it's telling me its 'undefined' is it possible that someone can find the solution and explain it to me! This isn't for marks its just for practice.
let wizardMan = {};
wizardMan.first_name = "Gorrok: ";
spells = ['abracadabra', 'cadabraabra', 'wooz'];
var randomSpell = [Math.floor(Math.random()*spells.length)];
wizardMan.getSpell = function(){
console.log(this.first_name + ' ' + this.spells);
return this.first_name + ' ' + this.spells;
}
wizardMan.getSpell();
Remove the this keyword from spells, spells is global
variable and not part of this
wizardMan.getSpell = function(){
console.log(this.first_name + ' ' + spells);
return this.first_name + ' ' + spells;
}
SEE OUTPUT
Thanks, PLEASE COMMENT if there is any concern.
Hello fellow programmers :D I have a little issue, this is a prep for an upcoming...
could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...