Kursinnehåll
Introduction to JavaScript
Introduction to JavaScript
1. Getting Started
First Javascript Console ApplicationChallenge: Showing some OutputChallenge: Outputing Multiple LinesDealing with NumbersChallenge: Working with NumbersChallenge: Calculating the Speed of a CarChallenge: Calculating Area of a TrapeziumOutputting Multiple ValuesChallenge: Consoling Meaningful OutputHow to Use Comments in Javascript?Challenge: Adding a CommentMulti-Line CommentsChallenge: Commenting out CodeWhat Is JavaScript anyway?
2. Manipulating Data
Storing DataChallenge: Declaring a VariableChallenge: Accessing Data From a VariableChallenge: Fixing Variable NamesChallenge: Reassigning a VariableConstantsChallenge: Declaring & Using ConstantsPerforming Arithmetic On VariablesChallenge: Making a Salary CalculatorChallenge: Adjusting Salary with a BonusExploring Primitive Data TypesChallenge: Declaring a Boolean ValueHow different Data Types InteractChallenge: Concatenating StringsChallenge: Creating User Profile & Activity Details
3. Conditional Statements
Comparison OperatorsChallenge: Checking Age EligibilityThe `if` StatementChallenge: Weather-Based Outfit RecommenderChallenge: Even or OddNested Conditional StatementsThe `else` ClauseChallenge: Improving Even or Odd CheckerChallenge: Temperature AdvisorThe `else if` ClauseChallenge: Grade Categorizer` AND` Logical OperatorChallenge: Checking if a Number is Even and PositiveOR Logical OperatorChallenge: Accessing Control System
4. Mastering Functions
What Are Functions?Challenge: Simple FunctionChallenge: Calculating the Speed of a CarScopesPassing Data into FunctionsChallenge: Fixing the Speed FunctionChallenge: Improving the Grade CategorizerTask: Defining a Compound FunctionReturning Data from FunctionsDefault ValuesChallenge: Email Auto-Responder with Default Parameters
5. Exploring Arrays
What Are Arrays?Challenge: Defining An ArrayChallenge: IndexingAdding Values to an ArrayChallenge: Pushing Elements to an ArrayRemoving Elements from an ArrayChallenge: Practicing `pop` & `shift`The `length` PropertyChallenge: Counting ElementsThe `includes` MethodChallenge: Searching for Animals in the Zoo
The `do-while` Loop
The do-while
is very similar to a while
loop, except it is always executed at least once, even if the loop condition is false
.
Another difference is that the code block is executed before the loop condition is checked.
The general syntax of a do-while
loop is the following:
js
The flowchart describes the execution process of a do-while
loop:
For example, following is a program which uses a do-while
loop to print the first ten even numbers:
let i = 1; do { console.log(i * 2); i += 1; } while (i <= 10);
Even if we change the value of i
, such that the condition becomes false
, the code block will still execute at least once:
let i = 11; do { console.log(i * 2); i += 1; } while (i <= 10);
1. What is the key difference between a while
loop and a do-while
loop?
2. What will be the output of the following code?
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 6. Kapitel 5