Kursinnhold
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
Comparison Operators
Definition
Comparison Operators, as expressed by the name, are operators that can be used for comparing data.
For example, we can use the equals to (==
) operator to check if two values are equal. This outputs true
or false
based on whether the two values are equal or not.
let a = 5; let b = 10; console.log(a == b);
The expression a == b
is known as a boolean expression because it evaluates into a boolean value (true
or false
).
Note
The equals to operator (==
) is not the same as the assignment operator (=
).
There's a similar operator known as the not equals to (!=
) operator. It simply returns true
if the two values are not equal:
let a = 5; let b = 10; console.log(a != b);
There are some other operators which can be used for comparing values:
1. What will be the output of the following code?
2. Which of the following operators checks if two values are equal?
3. What is the difference between =
and ==
in JavaScript?
4. What will be the output of this code?
5. Which of the following statements will return true
?
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 3. Kapittel 1