WorksheetsHTML Basics Quiz
Total questions: 20
Worksheet time: 10mins
Which is the correct way to write inline JavaScript?
<script> alert("Hi") </script>
<button onclick="alert('Hi')">Click</button>
<script src="app.js"></script>
alert('Hi')
Which tag is used for internal JavaScript?
<javascript>
<script>
<js>
<style>
External JavaScript file must have which extension?
.js
.css
.html
.py
How do you declare a variable in JavaScript?
variable x;
var x;
define x;
int x;
Which statement accesses an element by id?
Which event occurs when a user clicks?
onpress
onclick
onmouse
clickdo
How to write a function in JS?
function myFunc() { }
def myFunc() { }
func = myFunc() { }
create myFunc() { }
Which operator is used for AND?
&
||
!
&&
Which operator is used for OR?
&&
||
!
&
Which string method returns length?
size()
len()
length
count()
DOM stands for?
Document Output Model
Direct Object Manipulation
Document Object Model
Data Object Model
To add a class using JS:
el.addClass("red")
el.classList.add("red")
el.class.add("red")
add.class("red")
To remove a class:
el.remove("red")
el.classList.remove("red")
el.class.remove("red")
el.deleteClass("red")
Which one is NOT a loop?
for
while
repeat
do while
To stop a loop:
break
finish
stop
end
Which symbol is used for single-line comments in JavaScript?
#
//
/*/
--
Which function is used to print output to console?
print()
console.write()
log()
console.log()
Which string method converts to uppercase?
upper()
toUpper()
toUpperCase()
makeUpper()
Which operator is used to check NOT equal?
=/=
!=
<>
!==
Which creates a paragraph element using DOM?
document.create("p")
document.newElement("p")
new Element("p")
document.createElement("p")
