JavaScript Basics Flashcards
1
Q
What is JavaScript used for in websites?
A
To add interactivity and dynamic behaviour.
2
Q
What is a variable in JavaScript?
A
A container for storing data (e.g. let name = “Alex”).
3
Q
What is an if statement?
A
A condition that runs code only if it’s true.
4
Q
What is a function in JavaScript?
A
A block of code that performs a task and can be reused.
5
Q
How do you get input from a user in JavaScript?
A
Using prompt() (e.g. let name = prompt(“Enter your name”)).