Save
A-level Computer Science
School Notes
JavaScript
Save
Share
Learn
Content
Leaderboard
Share
Learn
Created by
Ana Saker
Visit profile
Cards (52)
What is required to run JavaScript?
A
browser
View source
How do you include JavaScript in an HTML document?
Add
JavaScript
code
between <
script
>
tags
View source
What is the purpose of the <title> tag in an HTML document?
It
sets
the
title
of the
web page
View source
What command is used to display an alert in JavaScript?
window.alert(
)
View source
What is the key difference in syntax between JavaScript and Python?
JavaScript
uses
curly brackets
, Python
uses
indentation
View source
What command is used in Python to output to the console?
print
View source
How can you output to the browser's console in JavaScript?
Using
console.log()
View source
What keyboard shortcut opens the console in most browsers?
Control-Shift-J
View source
How can you display output in a pop-up window in JavaScript?
Using
window.alert
()
View source
What does document.write() do in JavaScript?
It
outputs
directly onto the
HTML
page
View source
What is the purpose of the .innerHTML property in JavaScript?
To change the
value
of HTML
elements
View source
How do you declare a variable in JavaScript?
Using the
var
command
View source
How does JavaScript handle data types for variables?
It does not differentiate between
integer
and
float
View source
What is a versatile way to get user input in JavaScript?
Create a
form
on the page
View source
What is the focus of the spec regarding input methods in JavaScript?
Focus is on using the input once
received
View source
What is the purpose of the switch structure in JavaScript?
To handle multiple
conditions
View source
How does a simple if statement differ between Python and JavaScript?
JavaScript uses
parentheses
and
curly brackets
View source
What is the syntax for a for loop in JavaScript?
for (let i = 0; i <
10
; i++)
View source
How do you iterate through a list in JavaScript?
Using
for
(let i of list)
View source
What is the syntax for a while loop in JavaScript?
while (
condition
) {}
View source
What is the purpose of the do...while loop in JavaScript?
To execute code
at least once
View source
What is the JavaScript equivalent of Python's 'and' logical operator?
&&
View source
How
do you concatenate two strings in JavaScript?

Using str.concat(str)
View source
What is the output of str.charAt(3) in JavaScript?
Character in the
3rd
position
View source
What are the exercises to practice JavaScript input handling?
Create a page with two input boxes for name and number.
Create a page with two input boxes for two
numbers
, output the larger.
Create a page with three input boxes for three numbers, output the smallest.
Create a page for a times table based on user input.
Create a page to find the
sum
of
integers
between two numbers.
Create a page to return all integers between two given numbers.
Create a page to rearrange digits of a
three-digit
number for maximum value.
View source
What are common string manipulation functions in JavaScript?
str.
charAt
(index): Return character at index
str.
substring
(start, end): Return substring from start to end
str.
length
: Return length of string
str.
indexOf
('x'): Find first occurrence of 'x'
str.
split
(): Split string into array
str.
concat
(str): Concatenate two strings
str.
trim
(): Remove whitespace from ends
str.
replace
(a, b): Replace occurrences of 'a' with 'b'
View source
What is the output of str.length in JavaScript?
Length
of
the
string
View source
How do you find the first occurrence of a character in a string in JavaScript?
Using
str.indexOf
('x')
View source
What is the output of str.split(',') in JavaScript?
Array
of strings split at ','
View source
What is the purpose of the exercises related to string manipulation?
To practice
JavaScript
string handling
View source
What is the output of str.replace(a, b) in JavaScript?
Replace
occurrences
of 'a' with 'b'
View source
What does str.trim() do in JavaScript?
Removes
whitespace from the
beginning
and
end
View source
How can you check if two strings are palindromes in JavaScript?
By comparing the strings in
reverse
View source
How can you extract the domain name from an email address in JavaScript?
By splitting the
string
at
'@'
View source
What is the output of reversing a string in JavaScript?
The string written backwards
View source
How can you ensure an email address does not exceed a certain length in JavaScript?
By cutting the length of
names
if needed
View source
What is the purpose of the exercises related to user input?
To practice
handling
user input in
JavaScript
View source
What is the output of the exercise that asks for a times table?
Prints
the times table for the
given
number
View source
What is the output of the exercise that asks for the smallest of three numbers?
Outputs
the
smallest
of
the
three
numbers
View source
What is the output of the exercise that sums integers between two numbers?
Returns
the
sum
of
all integers between
View source
See all 52 cards