Define an array with conditional element in JavaScript

Write a function that takes an array with arbitrary elements and a number as arguments and returns a new array. The first element should be either the given number itself or zero if the number is smaller than 6.

The other elements should be the elements of the original array. Try not to mutate the original array

const getNewArr = (arr, val) => {
   const firstElm = val >= 6 ? val : 0;
   let result = [];
   result.push(firstElm);
   for(let i =0; i < arr.length; i++) {
       result.push(arr[i]);
   }
   return result;
}

const inputArr = [null, false];
const inputValue = 8;
console.log(getNewArr(inputArr, inputValue)) 

// Output:
[8, null, false]