Font size
WorksheetsRandom, Parse and String Review
Total questions: 15
Worksheet time: 44mins
How can you convert a string into a decimal number in JavaScript
parseDecimal()
parseFloat()
stringToFloat()
parseRandom()
What data type does a prompt always return in JavaScript?
number
Boolean
object
string
What is the purpose of using a prompt in JavaScript
take input from the user
create comments in the code
display messages to the user
import external modules, such as "prompt sync"
Which method is used to convert a string into an integer in JavaScript?
parseString()
parseInt()
toInt()
stringTolnt()
What does the const keyword indicate when declaring a variable in JavaScript?
The value of the variable cannot be changed after initialization
The value of the variable must be a number value
The variable can only be accessed by a specific piece of code
The variable must be changed after initialization
Given the code line below - which statement is true.
const prompt = require("prompt-sync")();
the require method is used to include external modules/files in a program
the name prompt, variable name must always be used in the require instance
the const use will allow the variable prompt to be changed throughout the program
the option prompt is calling internal code to process information
Which of the following code statement will generate random numbers (integers) in JavaScript
between -10 and 3?
let random5=Math.floor(Math.random()*14-10)
let random5=Math.floor(Math.random()*-10+3)
let random5=Math.floor(-10)Math.random(3)*1
let random5=Math.floor(Math.random()*14-10
What line of code will generate a random integer number between 4 and 15, including those values
let random2=Math.floor(Math.random()*12+4)
let random2=Math.floor(Math.random()*15+4)
let random2=Math.floor(Math.random(4)*15)
let random2=Math.floor(4)Math.random(15)*1
What is a string?
a value of a variable that has been input by a user
a pattern of characters that a user has input through parse
a sequence of characters that is stored in memory
characters inclusive of numbers that are used to calculate various values in required memory
JavaScript supports two syntax options for strings- double or single quotes to hold the string values - in this class we will use single quotes
TRUE
FALSE
What is the ASCII table?
values that computers use to transfer data into characters
interpretations of Boolean values into special characters such as &,%,$
characters that can be use in a const variable to be interpreted as Boolean
memory values used in JavaScript to convert numbers to misused characters
Every character of a string has an index associated with it. The index of the first character in a string is one.
TRUE
FALSE
Any data that is entered by the user will come into the program as a string datatype.
TRUE
FALSE
Parsing is the process of converting a piece of string data into a piece of numerical data.
TRUE
FALSE
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)
parseInt()
parseFloat()
parseRandom()
parseConst()
