# Javascript array weirdness

**URL:** <https://forum.kirupa.com/t/javascript-array-weirdness/332332>\
**Category:** Uncategorized\
**Created:** [April 28, 2014, 5:30am UTC](https://forum.kirupa.com/t/javascript-array-weirdness/332332 "2014-04-28T05:30:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghandolhagen](https://avatars.discourse-cdn.com/v4/letter/g/d9b06d/32.png) [@ghandolhagen](https://forum.kirupa.com/u/ghandolhagen)\
**Post date:** [April 28, 2014, 5:30am UTC](https://forum.kirupa.com/t/javascript-array-weirdness/332332/1 "2014-04-28T05:30:01Z")

</div>

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 😃

```auto

<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>

```
