make return the largest numeric value within the array, javascript [duplicate]

This is the code I’m trying to get it to work, the problem is it just checks up to the 8th value, then disregards the rest for some reason

function a(){
    let nums = [12,11,23,22,21,34,33,55,44,43,32,41,100]
    let nam;
    let b = 1
    let a = 0

    document.body.innerHTML += "<br>a = "+nums.length

    for(let x=0;x<=nums.length;x++){
        if(nums[a]>nums[b]){
            nam = nums[a]
            b++
        }else{
            nam = nums[b]
            a++
        }
        document.body.innerHTML += "<br>a = "+nums[a]
        document.body.innerHTML += "<br>b = "+nums[b]
        document.body.innerHTML += "<br>nam = "+nam
    }
}
a()