Loops in Javascript – Programming Virgin




Javascript Loops: https://codebabes.com/courses/programming-virgin/programming-loops
Main JS course!: https://codebabes.com/courses/programming-virgin-javascript

In programming there is a lot of repetition. That’s the thing about computers, they can do stuff over and over again really efficiently. When you’re writing code for a program, there is a shortcut for doing things over and over again. It’s called a loop.

Let’s say you want a piece of code repeated a bunch of times, that’s what a loop can do for you.

We’ll start with the most basic loop, called the while loop. It’s like the if-statement where if something is true it will do something, except it will do that thing over and over again.

Start with while, then parentheses, inside the parentheses, we put our condition. Then, braces, this is where we put the statements or functions we want to execute.

Let’s set a variable counter equal to 0. Then in our while loop parentheses we’ll check if counter is less than or equal to 10. Then let’s add console log “I’ll be back” as the statement to run while the counter is less than or equal to 10. If we just ran it like this it would crash the browser since it would be an infinite loop. The counter value would never be greater than 10, so, the condition would never be false. Let’s log the counter variable, you’ll see it prints zero forever.

What we need to do is increment the counter. Remember the shortcut operator for this? It’s the plus plus operator. Let’s add that to the block.

Let’s add an alert that will run after the loop stops, we’ll do alert “hasta la vista baby” and concatenate the counter variable onto the end. Let’s run this shit!

And boom, hasta la vista baby, and the counter is equal to 11. During the last loop the counter value was 10, but got one more added on so the loop stopped and the alert was executed.

Original source


43 responses to “Loops in Javascript – Programming Virgin”

  1. This series is great. Granted it's a very high altitude overview, but that's a good thing. Not every coding vid has to be an overcaffeinated dweeb mumbling about shell commands. This makes getting to know dev entertaining, fun, and a little more right brained, and of course sexy. And I promise lots of women are watching these too.

  2. code explanations with the animations & off color variable names makes these some of the best for understanding what the codes doing, but the intro is a turn off. It's a bit overboard waiting for it to end is like finger nails on chalk boards

  3. I usually see women dressed like her in other kind of videos… In this context I have to say I really hate it and I find it to be extremely degrading for women and programmers alike (let them be male or female).
    This video not only assumes that only young male teenagers are interested in programming – the "virgin" – but also that the one way for them to pay attention is to show half-naked women "No brain just boobs!".
    In addition to that this type of content has so many perverse effects: for instance do you really think that programming is just writting few pieces of code with the poster of a pin-up in the background? Such things prevent programming from being taken more seriously and women from wanting to code…
    You simply disgust me.

    TD;DR: Hate it, reinforces stereotype regarding "programming" as being male-only and depicts women only as a sexual object.

  4. GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS  GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS  GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS GALIFIANAKIS

Leave a Reply