• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

addEventListener and buttons

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created this script:



It doesn't work and I can't see why. This script should print out Even if you push the button when the value is even, otherwise "Uneven".

Thanks!
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dani Deliani wrote:It doesn't work and I can't see why.



First thing: welcome to the Ranch!

Second: just saying "it doesn't work" isn't very helpful. In the future, please describe the issue and the steps you have taken to debug it in more detail.

Third: have you used the debugger in the browser to step through the code and see what actually happening and where it is going awry?

And finally: your code is sloppy. The if and else clauses of a conditional statement should always be enclosed in braces. Tighten up your code and you may be pleasantly surprised.
 
Dani Deliani
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Dani Deliani wrote:It doesn't work and I can't see why.



First thing: welcome to the Ranch!

Second: just saying "it doesn't work" isn't very helpful. In the future, please describe the issue and the steps you have taken to debug it in more detail.

Third: have you used the debugger in the browser to step through the code and see what actually happening and where it is going awry?

And finally: your code is sloppy. The if and else clauses of a conditional statement should always be enclosed in braces. Tighten up your code and you may be pleasantly surprised.



Thanks!

How do I use the debugger? I don't get any error messages.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See the first section of the JavaScript FAQ at https://coderanch.com/t/660075/Wiki/Javascript-Links
 
reply
    Bookmark Topic Watch Topic
  • New Topic