0
0
Javascriptprogramming~10 mins

Basic input concepts (prompt overview) in Javascript - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to ask the user for their name using prompt.

Javascript
const name = [1]('What is your name?');
Drag options to blanks, or click blank then click option'
Aconsole.log
Balert
Cprompt
Dconfirm
Attempts:
3 left
💡 Hint
Common Mistakes
Using alert instead of prompt
Using console.log instead of prompt
2fill in blank
medium

Complete the code to convert the input string to a number.

Javascript
const age = Number([1]);
Drag options to blanks, or click blank then click option'
AageInput
Bprompt('Enter your age')
C'30'
DparseInt('25')
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable that is not defined
Passing a string literal instead of prompt
3fill in blank
hard

Fix the error in the code to correctly store user input in a variable.

Javascript
let city;
city = [1]('Enter your city');
Drag options to blanks, or click blank then click option'
Aprompt
Balert
Cconsole.log
Dconfirm
Attempts:
3 left
💡 Hint
Common Mistakes
Using alert or confirm instead of prompt
Trying to assign console.log output
4fill in blank
hard

Fill both blanks to ask for a number and convert it to an integer.

Javascript
const input = [1]('Enter a number');
const number = [2](input);
Drag options to blanks, or click blank then click option'
Aprompt
BparseInt
CNumber
Dalert
Attempts:
3 left
💡 Hint
Common Mistakes
Using alert instead of prompt
Using Number instead of parseInt when integer is needed
5fill in blank
hard

Fill all three blanks to get user input, convert to number, and check if it is positive.

Javascript
const input = [1]('Enter a number');
const num = [2](input);
const isPositive = num [3] 0;
Drag options to blanks, or click blank then click option'
Aprompt
BNumber
C>
DparseInt
Attempts:
3 left
💡 Hint
Common Mistakes
Using parseInt instead of Number for conversion
Using < instead of > for comparison