JavaScript Tutorial For Beginners #12 – If Statements




Hi all. In this JavaScript tutorial for beginners, we’re going to take our first look at control flow – if statements. If statements are alive everywhere you look in the world. If you perform an action, there will be a corresponding reaction or result. This concept is used in programming too.

If statements can be used to check a variety of things in JavaScript, such as whether a certain element has a particular class associated with it, or to check if an element is showing on a web page. They’re an extremely important aspect of JS, and will be VERY helpful in your future coding!

As usual, any questions just ask away :).

SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

========== JavaScript for Beginners Playlist ==========

========== CSS for Beginners Playlist ==========

========== HTML for Beginners Playlist ==========

========== The Net Ninja ============

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

========== Social Links ==========

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

Original source


20 responses to “JavaScript Tutorial For Beginners #12 – If Statements”

  1. Question – Noticed you put the <script> tag in the body of the .html page. Can you clarify when you would put the tag in the <head> and when you would put it in the body. (I do know the placement order in the body matters)

  2. What I don’t understand is the combination of what I would called a regular statement like “I like meat” and using num to get the true or false return. Is there an example that we use in daily life or on a website that would help clarify why we would ever use nums instead of just saying if”I like meat” = true else = false? Thank you btw these videos are saving me!

  3. Hey i am getting error while var youLikeMeat = true;
    If(youLikeMeat) { document.write("here is…"} I am not getting any output , i perfectly paired my html with js still nothing showing up in my chrome, is this is problem with sublime text ?

  4. Hello The Net Ninja, i hope you still see this. i have a question in this lesson. when we are saying var youLikeMeat = true and then writing the if statement . if (youLikeMeat) { document.write ("Here's the Meat Menu"); } the question is where is the conditional here ? and how when we change the var value it can reads it without any conditional comparison ?

  5. Sir, I love your videos and and I am really thankful for putting this online, I am trying to follow your exact steps so I also downloaded Brackets but I don't know why I get ESLint and JSLint errors for example " document.write can be a form of eval" or "document is not defined." Could you tell me how to deal with this? Much appreciated..

Leave a Reply