jburridge Posted January 16, 2014 Share Posted January 16, 2014 I keep receiving this error, I'm not really sure why. Any help is greatly appreciated. Also, If I don't put the random integer inside my function will it still generate new random numbers or will it only generate 1 random number and stay that way? " ReferenceError: math is not defined var randomLoot=loot[math.floor(math.random()*loot.length)]; " movement.js var randomLoot=loot[math.floor(math.random()*loot.length)]; var randomRareLoot=rareLoot[math.floor(math.random()*rareLoot.length)]; var randomInteger=math.random()+11; var randomInteger2=math.random()+11; //each new movement starts this function to find a random item function eventMove () { if (randomInteger==randomInteger2) { characterBackpack+randomRareLoot; console.log("You found a rare item!"); console.log(characterBackpack); } else if (randomInteger==1||5||9) { characterBackpack+randomLoot; console.log("You found a item!"); console.log(characterBackpack); } } Link to comment https://forums.phpfreaks.com/topic/285425-math-error-undefined/ Share on other sites More sharing options...
jburridge Posted January 16, 2014 Author Share Posted January 16, 2014 I believe this may help as well items.js var loot=[]; loot[0]=crudeSword; loot[1]=brokenArmor; var rareLoot=[]; rareLoot[0]=infinityBlade; rareLoot[1]=superiorChestpiece; //One-Handed Weapons var infinityBlade="Infinity Blade"; // 4 dmg var crudeSword="Crude Sword"; // 2 dmg //Chest Armor var brokenArmor="Broken Armor"; // 5 health var superiorChestpiece="Superior Chestpiece"; // 10 health Link to comment https://forums.phpfreaks.com/topic/285425-math-error-undefined/#findComment-1465482 Share on other sites More sharing options...
requinix Posted January 16, 2014 Share Posted January 16, 2014 It's called "Math", not "math". Javascript is case-sensitive. Link to comment https://forums.phpfreaks.com/topic/285425-math-error-undefined/#findComment-1465483 Share on other sites More sharing options...
jburridge Posted January 16, 2014 Author Share Posted January 16, 2014 Ohhhhhhh I see, Thanks a lot! Link to comment https://forums.phpfreaks.com/topic/285425-math-error-undefined/#findComment-1465484 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.