I have this simple issue that I can't figure out trying to find out the max from a string, yes it is a string, converting to a float. According to JS it can take an array... but everytime I try to find the max it is just printing the first value. In this case 13... not sure why? The expected result is 30.
Please help. Thanks!
function myFunction() {
var str = "13, 24, 30, 4";//30
var res = str.split(",");
var max = Math.max(parseFloat(res));
document.getElementById("demo").innerHTML = res+ " " + max;//test
}
resis an array.parseFloattakes a string.Math.maxdoes not take an array, but multiple arguments.