A while loop is something that frequently poses problems for even the most experienced programmers in JavaScript. In this video, Simon will walk you through on how to create an index, make your loop check the condition, and how to make sure you have the ability to increment or add the index. Simon also delves into the most commonly made errors in while loop coding and how to avoid it.
So I'm going to write some simple iteration code here, but before I do I have a…quick question for you and this is not a trick question, it's not a riddle, but…I am interested in the first answer, your gut answer that comes to mind.…Here is the question.…You need to build a straight fence and it must be 50 meters wide and you need…fence posts every 10 meters.…How many fence posts do you need?…Do you have your answer? Good!…Let's get into the code.…
So in my JavaScript here I'm going to create a simple While loop where I'll…show you how to do it and I'll show you one of the most common gotchas with iteration.…I want to make a variable called amount.…Start off at 0 and I want to add the number 100 to it 10 times.…So I'm going to create a loop to do that.…So when I create a loop as I mentioned there is always three parts to it, so…I'll add a few comments here just before we start to build it out.…First, we're going to create the index, then we're going to have the loop that…checks the condition, and at some point we need to have the ability to increment…
Author
Released
9/22/2011Finally, the course compares how code is written in several different languages, the libraries and frameworks that have grown around them, and the reasons to choose each one.
- Writing source code
- Understanding compiled and interpreted languages
- Requesting input
- Working with numbers, characters, strings, and operators
- Writing conditional code
- Making the code modular
- Writing loops
- Finding patterns in strings
- Working with arrays and collections
- Adopting a programming style
- Reading and writing to various locations
- Debugging
- Managing memory usage
- Learning about other languages
Skill Level Beginner
Duration
Views
Q: Using TextEdit with Mac OS 10.9 Mavericks?
Related Courses
-
Introduction
-
Welcome1m 13s
-
-
1. Programming Basics
-
What is programming?5m 45s
-
Writing source code5m 34s
-
-
2. Core Programming Syntax
-
Why JavaScript?4m 45s
-
Requesting input4m 50s
-
-
3. Variables and Data Types
-
Working with numbers5m 4s
-
Working with operators4m 47s
-
Properly using white space6m 46s
-
4. Writing Conditional Code
-
Setting comparison operators6m 59s
-
5. Modular Code
-
Breaking your code apart4m 1s
-
Understanding variable scope2m 23s
-
-
6. Iteration: Writing Loops
-
Introduction to iteration4m 28s
-
Writing a while statement5m 24s
-
Creating a for loop3m 39s
-
-
7. More About Strings
-
8. Collections
-
Working with arrays5m 46s
-
Array behavior5m 29s
-
-
9. Programming Style
-
Programming style5m 55s
-
Writing pseudocode4m 55s
-
-
10. Input and Output
-
Event driven programming7m 47s
-
Introduction to file I/O6m 51s
-
11. When Things Go Wrong
-
Introduction to debugging5m 57s
-
Understanding error messages3m 21s
-
Using debuggers8m 2s
-
-
12. Introduction to Object Orientation
-
Using classes and objects6m 28s
-
13. Advanced Topics
-
14. Exploring the Languages
-
Introduction to languages1m 42s
-
C-based languages4m 40s
-
The Java world3m 13s
-
Ruby3m 4s
-
Python2m 56s
-
Objective-C4m 3s
-
Libraries and frameworks3m 25s
-
-
Conclusion
-
Where to go from here1m 2s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Writing a while statement