wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Random, Parse and String Review

Total questions: 15

Worksheet time: 44mins

Name
Class
Date
1.

How can you convert a string into a decimal number in JavaScript

a)

parseDecimal()

b)

parseFloat()

c)

stringToFloat()

d)

parseRandom()

2.

What data type does a prompt always return in JavaScript?

a)

number

b)

Boolean

c)

object

d)

string

3.

What is the purpose of using a prompt in JavaScript

a)

take input from the user

b)

create comments in the code

c)

display messages to the user

d)

import external modules, such as "prompt sync"

4.

Which method is used to convert a string into an integer in JavaScript?

a)

parseString()

b)

parseInt()

c)

toInt()

d)

stringTolnt()

5.

What does the const keyword indicate when declaring a variable in JavaScript?

a)

The value of the variable cannot be changed after initialization

b)

The value of the variable must be a number value

c)

The variable can only be accessed by a specific piece of code

d)

The variable must be changed after initialization

6.

Given the code line below - which statement is true.

const prompt = require("prompt-sync")();

a)

the require method is used to include external modules/files in a program

b)

the name prompt, variable name must always be used in the require instance

c)

the const use will allow the variable prompt to be changed throughout the program

d)

the option prompt is calling internal code to process information

7.

Which of the following code statement will generate random numbers (integers) in JavaScript

between -10 and 3?

a)

let random5=Math.floor(Math.random()*14-10)

b)

let random5=Math.floor(Math.random()*-10+3)

c)

let random5=Math.floor(-10)Math.random(3)*1

d)

let random5=Math.floor(Math.random()*14-10

8.

What line of code will generate a random integer number between 4 and 15, including those values

a)

let random2=Math.floor(Math.random()*12+4)

b)

let random2=Math.floor(Math.random()*15+4)

c)

let random2=Math.floor(Math.random(4)*15)

d)

let random2=Math.floor(4)Math.random(15)*1

9.

What is a string?

a)

a value of a variable that has been input by a user

b)

a pattern of characters that a user has input through parse

c)

a sequence of characters that is stored in memory

d)

characters inclusive of numbers that are used to calculate various values in required memory

10.

JavaScript supports two syntax options for strings- double or single quotes to hold the string values - in this class we will use single quotes

a)

TRUE

b)

FALSE

11.

What is the ASCII table?

a)

values that computers use to transfer data into characters

b)

interpretations of Boolean values into special characters such as &,%,$

c)

characters that can be use in a const variable to be interpreted as Boolean

d)

memory values used in JavaScript to convert numbers to misused characters

12.

Every character of a string has an index associated with it. The index of the first character in a string is one.

a)

TRUE

b)

FALSE

13.

Any data that is entered by the user will come into the program as a string datatype.

a)

TRUE

b)

FALSE

14.

Parsing is the process of converting a piece of string data into a piece of numerical data.

a)

TRUE

b)

FALSE

15.

Parsing is the process of converting a piece of string data into a piece of numerical data. What are the two methods of Parse (select two)

a)

parseInt()

b)

parseFloat()

c)

parseRandom()

d)

parseConst()