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”
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)
i love you man
My bracket live preview isn't working ..how to connect to browser
5:32 I hope you mean that my number is greater than 9.
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!
I am getting 'document is not defined' error after excluding same code which is mentioned in video
You like meat..LOL!!!
then else is exactly the same than say if not, thanks
Question: I am confused on the part where you stated that var youLikeMeat = False, you if statement was true. How was that so if the value for if you like meat was set to a value of false.
Excellent work. I'm really getting all this; not just the "what" but the "why".
//Life Motto
if(sad()===True) {
sad().stop;
beAwesome();
}
It's an old tutorial of yours but I'd still like thank you for it !
Good
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 ?
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 ?
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..
Thanks for the tutorial. TT
I switch on the beginning of your videos multiply times only to hear the oooooooooaaaaa hhh
Finally the fun part. "IF you take a crap in public, you'll wind up in prison" LMAO that right there woke me the F up!
Thanks these videos are really helpful. Keep the good work alive 😀