Can someone explain to me why this code does not work correctly? Fairly simple and I have tested many different things to try and figure it out. I even took video capture of it failingā¦
Cheers
<html>
<script>
var weaponName = ["gun", "knife", "rocket"];
var weaponWeight = ["3", "1", "15"];
var weaponDamage = ["3", "2", "10"];
var mostDam = "";
var baseDamage = 1;
for(var i=0; i<weaponName.length; i++){
if(weaponDamage* > baseDamage){
baseDamage = weaponDamage*;
mostDam = weaponName*;
}
}
console.log("the most damaging weapon is: " + mostDam); //expect "rocket" outputs "gun"
console.log("its damage is: " + baseDamage); // expect "10" outputs "3"
</script>
</html>