jeudi 5 novembre 2020

problem with an javascript inputs in javascript

I have a exercise where i need to take two inputs and check if they both equal to one.

If yes console.log positive else console.log false

I tried something like this:

function isPositive(firstNum, secondNum) {
  if (firstNum !== 1) {
    console.log('no positive')
  } else if (secondNum === 1) {
    console.log('positive')
  }
}

isPositive(5, 7)
isPositive(5, 10)
isPositive(5, 6)
isPositive(5, 1)
isPositive(1, 1)

and then when i run it in chrome console this

isPositive(5, 7)
not positive
undefined

isPositive(5, 10) 
not positive
undefined

isPositive(5, 6) 
not positive
undefined

isPositive(5, 1) 
not positive
undefined

isPositive(1, 1)
 yes positive
undefined

Aucun commentaire:

Enregistrer un commentaire