Need help understanding this line of conditional logic

let password = 'cat dog'
if (password.length => 6){
  if ( password.indexOf (' ') !==-1 ) {
      console.log ('Password cannot include spaces!')
}else {
      console.log('Valid Password')

I’m having trouble grasping the concept of the nested conditional code where it checks if there’s spaces in the password,

( password.indexOf (’ ') !==-1 )

The the use of the non equality operator and what its actually doing here is what I think is tripping me up.

The indexOf method returns -1 if the character is not found. I’m not sure why there are []s around the input though…

yeah oops it should be paras in there.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.