Why is chrome giving me a TypeError when finding largest number in array?

I have the following code to find the largest number in an array:

function max(input) {
 var maxNum = 0;
 for(var i = 0; i <= input.length; i++) {
     if(maxNum < input[i]) {
         maxNum = input[i];
    return maxNum;
max([1, 2, 3, 7]);

When I run it in Google Chrome, Edge, or Firefox I get:

max.js:20 Uncaught TypeError: Cannot read property 'length' of undefined
    at max (max.js:20)
    at :1:1

but when I run it on pythontutor for JavaScript, I get the correct results without any syntax error.