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
Passing Data into Functions
We can pass data into functions using parameters:
js
A parameter acts like a local variable inside the function. However, it takes up the value of the corresponding argument that is passed into the function at the function call.
function sum(a, b) { console.log(a + b); } sum(1, 2); // Output: 3 sum(5, 10); // Output: 15 sum(20, 30); // Output: 50 sum(33, 37); // Output: 70
An argument is the actual value passed into a function when calling it:
Example: In
sum(1, 2)
, the values1
and2
are arguments;
A parameter is a placeholder inside the function definition that receives the argument’s value:
Example: In
function sum(a, b)
,a
andb
are parameters.
Study More
A function in which other functions are called is known as a compound function. A compound function combines smaller functions to accomplish a larger task.
1. How many parameters does this function have?
2. What will be the output of this code?
3. Which of the following is true?
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 4. Kapittel 5