NEW
Font size
WorksheetsWeb Development Mastery
Total questions: 10
Worksheet time: 5mins
How do you center a div using Flexbox?
Set the parent div to 'display: flex; justify-content: center; align-items: center;'
Set the parent div to 'display: block; margin: auto;'
Apply 'text-align: center;' to the parent div
Use 'display: grid; place-items: center;' on the parent div
What is a function in JavaScript?
A function in JavaScript is a type of variable that cannot be reused.
A function in JavaScript is a reusable block of code that can take inputs, execute logic, and return a value.
A function in JavaScript is a single line of code that performs a task.
A function in JavaScript is a method that only returns a value without taking inputs.
What is the difference between function scope and block scope in JavaScript?
Function scope restricts variable access to the function, while block scope restricts access to the block.
Block scope allows access to variables outside the block.
Function scope allows access to all variables globally.
Function scope is only applicable to loops and conditionals.
How can you make a website responsive to different screen sizes?
Avoid using any CSS styles.
Use only fixed pixel sizes for layout.
Implement JavaScript for all layout changes.
Use CSS media queries, flexible layouts, and scalable images.
What method is used to select an element in the DOM?
getElementsByTagName
getElementsByClassName
getElementById
querySelector
How do you change the text content of an HTML element using JavaScript?
document.getElementById('elementId').innerHTML = 'New Text';
document.getElementById('elementId').setText('New Text');
document.querySelector('#elementId').text = 'New Text';
document.getElementById('elementId').textContent = 'New Text';
What is the purpose of the 'display' property in CSS?
To add animations to elements on a web page.
To define the color of text on a web page.
To specify the font size of elements.
To control the layout and rendering of elements on a web page.
How can you create a two-column layout using CSS Grid?
Use CSS: .container { display: block; }
Use CSS: .container { display: inline; }
Use CSS: .container { display: grid; grid-template-columns: 1fr 1fr; }
Use CSS: .container { display: flex; }
What is the significance of the 'this' keyword in JavaScript functions?
The 'this' keyword is a special function that executes code in JavaScript.
The 'this' keyword in JavaScript functions signifies the context of execution, determining the value it refers to based on how the function is invoked.
The 'this' keyword always refers to the global object in JavaScript.
The 'this' keyword is used to declare variables in JavaScript functions.
How do you add an event listener to a button in JavaScript?
button.onClick(function() { /* your code here */ });
button.addEventListener('click', function() { /* your code here */ });
button.attachEvent('onclick', function() { /* your code here */ });
button.addEvent('click', function() { /* your code here */ });
