JS Функции. Калькулятор

  let calculate = function(firstNumber,secondNumber,operator){
      let result;
      if(operator==='+'){
        result = Number(firstNumber)+Number(secondNumber);
      }
      if(operator==='-'){
        result = Number(firstNumber)-Number(secondNumber);
      }
      if(operator==='*'){
        result = Number(firstNumber)*Number(secondNumber);
      }
      if(operator==='/'){
        result = Number(firstNumber)/Number(secondNumber);
      }
      return result;
    }

Тоже самое, только немного по короче.

let calculate = function(firstNumber, secondNumber, operator){
  
  firstNumber = Number(firstNumber);
  secondNumber = Number(secondNumber);
  
  if(operator === '+'){
    return firstNumber + secondNumber; 
  }
  
   if(operator === '-'){
    return firstNumber - secondNumber; 
  }
  
  if(operator === '*'){
    return firstNumber * secondNumber; 
  }
  
   if(operator === '/'){
    return firstNumber / secondNumber; 
  }
  
}