wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Intro to JS: Variables & Values

Total questions: 8

Worksheet time: 6mins

Name
Class
Date
1.

What is the primary purpose of a scripting language like JavaScript?

a)

To create operating systems

b)

To write small programs or scripts for common tasks

c)

To design hardware components

d)

To manage databases

2.

Which of the following statements correctly declares a variable in JavaScript?

a)

`int number = 5;`

b)

`var number = 5;`

c)

`let number = 5;`

d)

`const number = 5;`

3.

Explain the difference between a variable and a value in JavaScript.

a)

A variable is a fixed number, while a value can change.

b)

A variable is a signifier that points to a value, which is the actual data.

c)

A variable is a type of data, while a value is a function.

d)

A variable is a string, while a value is a number.

4.

What is the output of the following JavaScript code? ```javascript var x = 10; var y = 5; console.log(x + y); ```

a)

5

b)

10

c)

15

d)

50

5.

Why is JavaScript considered a loosely typed language?

a)

Because it requires explicit type declarations for variables

b)

Because it automatically determines the type of a variable based on its value

c)

Because it does not support data types

d)

Because it only supports string and number types

6.

Given the following code, what will be the output? ```javascript var greeting = "Hello, "; var name = "Alice"; console.log(greeting + name); ```

a)

Hello,

b)

Alice

c)

Hello, Alice

d)

greeting + name

7.

Consider the following scenario: You need to store a user's age and name in a JavaScript program. Which data types would you use for each, and why?

a)

Use a String for age and a Number for name, because age is a sequence of characters.

b)

Use a Number for age and a String for name, because age is a numerical value and name is a sequence of characters.

c)

Use a Boolean for both, because they are simple data types.

d)

Use an Array for both, because they can store multiple values.

8.

What is the significance of using a REPL environment like Repl.it for learning JavaScript?

a)

It allows for the creation of complex web applications.

b)

It provides a platform to experiment and try out new ideas interactively.

c)

It is the only way to run JavaScript code.

d)

It automatically optimizes JavaScript code for performance.