Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Let 1/2 | Data Types and Variables
Introduction to JavaScript (staging)
course content

Зміст курсу

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

1. Introduction
2. JavaScript syntax
3. Data Types and Variables

bookLet 1/2

In the very first chapter of the section we learn that there are three ways to declare a variable:

  • let
  • const
  • var

In the later versions of Javascript language known as ES6(ES2015), the let keyword was introduced. It works better than the var keyword. The variables written with the let keyword can also be overwritten.

let has Block Scope:

Variables declared with the let keyword has block scope and cannot be accessed outside that scope, for example.

1234
if (2 == 2){ let name = 'David' } console.log(name)
copy

As you can see we get an error that says that the name is not defined.
Note:
Don’t worry about the if and == for now they will be covered in the later chapters.

Завдання

In the following code, a variable named city with the assigned value of Berlin has been given to you. You are also given an if statement that checks whether 4 is greater than 2 or not (for now, don’t worry about the if). Your task is to declare a variable with the same name as above inside the if with the value of London. Display the variable outside the if.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 7
toggle bottom row

bookLet 1/2

In the very first chapter of the section we learn that there are three ways to declare a variable:

  • let
  • const
  • var

In the later versions of Javascript language known as ES6(ES2015), the let keyword was introduced. It works better than the var keyword. The variables written with the let keyword can also be overwritten.

let has Block Scope:

Variables declared with the let keyword has block scope and cannot be accessed outside that scope, for example.

1234
if (2 == 2){ let name = 'David' } console.log(name)
copy

As you can see we get an error that says that the name is not defined.
Note:
Don’t worry about the if and == for now they will be covered in the later chapters.

Завдання

In the following code, a variable named city with the assigned value of Berlin has been given to you. You are also given an if statement that checks whether 4 is greater than 2 or not (for now, don’t worry about the if). Your task is to declare a variable with the same name as above inside the if with the value of London. Display the variable outside the if.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 7
toggle bottom row

bookLet 1/2

In the very first chapter of the section we learn that there are three ways to declare a variable:

  • let
  • const
  • var

In the later versions of Javascript language known as ES6(ES2015), the let keyword was introduced. It works better than the var keyword. The variables written with the let keyword can also be overwritten.

let has Block Scope:

Variables declared with the let keyword has block scope and cannot be accessed outside that scope, for example.

1234
if (2 == 2){ let name = 'David' } console.log(name)
copy

As you can see we get an error that says that the name is not defined.
Note:
Don’t worry about the if and == for now they will be covered in the later chapters.

Завдання

In the following code, a variable named city with the assigned value of Berlin has been given to you. You are also given an if statement that checks whether 4 is greater than 2 or not (for now, don’t worry about the if). Your task is to declare a variable with the same name as above inside the if with the value of London. Display the variable outside the if.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

In the very first chapter of the section we learn that there are three ways to declare a variable:

  • let
  • const
  • var

In the later versions of Javascript language known as ES6(ES2015), the let keyword was introduced. It works better than the var keyword. The variables written with the let keyword can also be overwritten.

let has Block Scope:

Variables declared with the let keyword has block scope and cannot be accessed outside that scope, for example.

1234
if (2 == 2){ let name = 'David' } console.log(name)
copy

As you can see we get an error that says that the name is not defined.
Note:
Don’t worry about the if and == for now they will be covered in the later chapters.

Завдання

In the following code, a variable named city with the assigned value of Berlin has been given to you. You are also given an if statement that checks whether 4 is greater than 2 or not (for now, don’t worry about the if). Your task is to declare a variable with the same name as above inside the if with the value of London. Display the variable outside the if.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 7
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
some-alt