Difficulty Solving JavaScript Exercise - Programming - HWzone Forums
adplus-dvertising
Skip to content
  • Create an account
  • About Us

    Hello Guest!

     
    Please note - in order to participate in our community, comment and open new discussions, you must join as a registered member.

    Our members enjoy many advantages, including the ability to participate in discussions, enjoy raffles and promotions for members of the site, and receive our weekly content directly by email.

    Do not like being harassed by email? You can register for the site but do not submit your registration to the weekly email updates.

Difficulty Solving JavaScript Exercise


Ron 88
 Share

Recommended Posts

Hello

Studying in a JavaScript book and I have difficulty with the exercise:

flight foo = thursday;
if (foo === 'Thursday' || foo === 'thursday' || foo === 5) {
    consul.log('Yay! Thursday! ')
}

What is the mistake that makes a console write?

Uncaught ReferenceError: thursday is not defined file: ///home/ron/Documents/JS/source.js: 1

Thanks!

Edited By Ron 88
Link to content
Share on other sites

Quote of mzn

You are missing first line quotes around the word thursday. If you do not treat the word as a string, the program thinks it changes. 

Thanks! I did not notice

 

a quote

Strengthens mzn, and in addition if you set thursday as a variable of some value even before you set foo, there would be no error

MZN your intention rather less I could understand.
Thanks

Link to content
Share on other sites

Quote of Ron 88

Thanks! I did not notice

 

MZN your intention rather less I could understand.
Thanks

If at the beginning of the code it said let thursday = something, it would not bounce an error

You can run and see:

let thursday = 'something' let foo = thursday;
if (foo === 'Thursday' || foo === 'thursday' || foo === 5) {
    consul.log('Yay! Thursday! ')
}
Link to content
Share on other sites

Quote of Randomness

If at the beginning of the code it said let thursday = something, it would not bounce an error

You can run and see:

let thursday = 'something' let foo = thursday;
if (foo === 'Thursday' || foo === 'thursday' || foo === 5) {
    consul.log('Yay! Thursday! ')
}

Walla-why is this actually happening that is possible anyway?

Link to content
Share on other sites

Join the discussion

You can then join the discussion and then join our community. If you already have an account with us, please Log in now To comment under your username.
Note that: The comment will appear to the surfers after approval by the board management team.

guest
Add a comment

×   The content pasted is with formatting.   Remove formatting

  Only 75 emoji are allowed.

×   Your link has been automatically assimilated.   Show as regular link

×   Your previous content has been automatically restored.   Clear all

×   You can not paste images directly. Upload or insert images from URL.

 Share

  • Latest news

  • Buzz-Zone: Everything hot on the net

×
  • Create new ...

At the top of the news:

new on the site

Amazon's parade continues

Amazon's parade continues

Come and be impressed by another list of great prices for quality hardware products and gadgets that can make your credit cards work overtime