Learn HTML - Form a story

In the main.js file, I don’t understand something in the cleanAndCap function.
What does the following line exactly ? if(!str) return null
Why does str is never declared ?
Is str an implicit string variable ?

str is a parameter of the cleanAndCap function.

code copied
// Cleans up and capitalizes the names of the animals
function cleanAndCap (str){
  if(!str) return null
  let temp = str.trim()
  return temp[0].toUpperCase() + temp.substring(1)

Thank you for answering. I knew it was a parameter.
I actually answered my own question a few minutes after asking it.

if(!str) return null 

This line of code is only there for the case no parameter is passed to the function.
Am I right ?

yes. that’s correct.

1 Like

Thanks for helping me out.