0

If a variable has been assigned a string and you tested it within an if statement it would be true, why?

  hide ='string'

  if (hide)  {                                  
   otherText.value = '';                      
  }
Joe Black
  • 81
  • 1
  • 8
  • 1
    "*it would be true*" - no, it would be [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), or true-ish, or not-[falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy). – David Thomas Nov 10 '22 at 15:24
  • 1
    It's to do with how JS coerces types. The duplicate I marked contains much more information on the subject – Rory McCrossan Nov 10 '22 at 15:30

0 Answers0