[Solved] Javascript if statement says 63>542 is true


You must using parseInt:

function low(numbers){
      var arr = numbers.split(" ")
      var highest = parseInt(numbers[0]);
      for(i = 0; i < arr.length; i++){
        if(parseInt(arr[i]) > highest){
          console.log(arr[i] +">"+ highest)
          console.log(parseInt(arr[i]) > highest)
          highest = parseInt(arr[i])
        }
      }
      alert(highest)
      return highest
    }

    low("4 5 29 4 0 -214 542 -64 1 -3 3 4 63 -6"); 

1

solved Javascript if statement says 63>542 is true