feat(curriculum): create javascript fundamentals quiz (#56565)

This commit is contained in:
Abhishek Khatri
2024-10-13 20:14:54 -04:00
committed by GitHub
parent 5e5fca65e4
commit a073b3978d

View File

@@ -17,439 +17,439 @@ Answer all of the questions below correctly to pass the quiz.
#### --text--
Placeholder question
What are default parameters?
#### --distractors--
Placeholder distractor 1
Parameters that should always be present in a function
---
Placeholder distractor 2
Parameters that are passed in an array
---
Placeholder distractor 3
Parameters that are destructured from an object
#### --answer--
Placeholder answer
Parameters that are optional and have a default value when not provided
### --question--
#### --text--
Placeholder question
What is the correct syntax for a default parameter in JavaScript?
#### --distractors--
Placeholder distractor 1
`function myFunction(param1 == defaultValue)`
---
Placeholder distractor 2
`function myFunction(param1: defaultValue)`
---
Placeholder distractor 3
`function myFunction(param1 || defaultValue)`
#### --answer--
Placeholder answer
`function myFunction(param1 = defaultValue)`
### --question--
#### --text--
Placeholder question
What does the rest parameter syntax allow you to do in JavaScript?
#### --distractors--
Placeholder distractor 1
Pass parameters by reference
---
Placeholder distractor 2
Provide a set default parameters
---
Placeholder distractor 3
Destructure an object into parameters
#### --answer--
Placeholder answer
Capture all arguments into one array
### --question--
#### --text--
Placeholder question
Which of the following is the correct syntax for the rest parameter in JavaScript?
#### --distractors--
Placeholder distractor 1
`function myFunction(restParams)`
---
Placeholder distractor 2
`function myFunction(restParams...)`
---
Placeholder distractor 3
`function myFunction([...restParams])`
#### --answer--
Placeholder answer
`function myFunction(...restParams)`
### --question--
#### --text--
Placeholder question
What does destructuring allows you to do in JavaScript?
#### --distractors--
Placeholder distractor 1
Build complex objects
---
Placeholder distractor 2
Serialize objects
---
Placeholder distractor 3
Merge arrays or objects
#### --answer--
Placeholder answer
Extract properties from objects and elements from arrays
### --question--
#### --text--
Placeholder question
Which of the following is a valid function name in JavaScript?
#### --distractors--
Placeholder distractor 1
`123function`
---
Placeholder distractor 2
`function-name`
---
Placeholder distractor 3
`function`
#### --answer--
Placeholder answer
`functionName`
### --question--
#### --text--
Placeholder question
Which of these is NOT a good practice for naming variables and functions in JavaScript?
#### --distractors--
Placeholder distractor 1
Use camelCase notation
---
Placeholder distractor 2
Start variable names with a letter, $ or _
---
Placeholder distractor 3
Using meaningful names
#### --answer--
Placeholder answer
Using reserved keywords as variable names
### --question--
#### --text--
Placeholder question
What is the primary purpose of a linter in JavaScript development?
#### --distractors--
Placeholder distractor 1
To format code automatically
---
Placeholder distractor 2
To optimize code for performance
---
Placeholder distractor 3
To create documentation for code
#### --answer--
Placeholder answer
To detect potential errors and style issues in code
### --question--
#### --text--
Placeholder question
Which of the following is NOT a linter for JavaScript?
#### --distractors--
Placeholder distractor 1
ESLint
---
Placeholder distractor 2
standardJS
---
Placeholder distractor 3
quick-lint-js
#### --answer--
Placeholder answer
Babel
### --question--
#### --text--
Placeholder question
Which of these describes accessibility?
#### --distractors--
Placeholder distractor 1
Making sure code is accessible to other developers
---
Placeholder distractor 2
Writing secure code
---
Placeholder distractor 3
Controlling who can access certain data
#### --answer--
Placeholder answer
Using events wisely to avoid locking out specific control types (keyboard, touchscreen users)
### --question--
#### --text--
Placeholder question
Why is using the `var` keyword considered bad practice in modern JavaScript?
#### --distractors--
Placeholder distractor 1
It's slower than `let` and `const`
---
Placeholder distractor 2
It causes a syntax error
---
Placeholder distractor 3
It doesn't allow type checking
#### --answer--
Placeholder answer
It has function scope instead of block scope, which can lead to unexpected behaviors
### --question--
#### --text--
Placeholder question
In JavaScript, how is memory for variables typically allocated?
#### --distractors--
Placeholder distractor 1
Manually by the developer
---
Placeholder distractor 2
By the browser
---
Placeholder distractor 3
By the server
#### --answer--
Placeholder answer
Automatically by the runtime engine
### --question--
#### --text--
Placeholder question
What is hoisting in JavaScript?
#### --distractors--
Placeholder distractor 1
Raising errors to the top of the code
---
Placeholder distractor 2
The process of creating new variables
---
Placeholder distractor 3
Automatically moving `var` declarations to the top of the block
#### --answer--
Placeholder answer
The process of moving variable declarations to the top of their scope
### --question--
#### --text--
Placeholder question
What is the purpose of modules in JavaScript?
#### --distractors--
Placeholder distractor 1
To improve code performance
---
Placeholder distractor 2
To make code more difficult to understand
---
Placeholder distractor 3
To create new programming languages
#### --answer--
Placeholder answer
To organize code into reusable units
### --question--
#### --text--
Placeholder question
In the context of JavaScript modules, what does `export` do?
#### --distractors--
Placeholder distractor 1
Save the code to disk
---
Placeholder distractor 2
Include external libraries in your code
---
Placeholder distractor 3
Publish your code to a public repository
#### --answer--
Placeholder answer
Make variables, functions or classes available to be imported by other modules
### --question--
#### --text--
Placeholder question
Which of these is NOT a valid way to declare a variable in JavaScript?
#### --distractors--
Placeholder distractor 1
`var myVariable = 'test'`
---
Placeholder distractor 2
`let myVariable = 'test'`
---
Placeholder distractor 3
`const myVariable = 'test'`
#### --answer--
Placeholder answer
`variable myVariable = 'test'`
### --question--
#### --text--
Placeholder question
In the context of JavaScript memory management, what are memory leaks?
#### --distractors--
Placeholder distractor 1
Oversized memory use
---
Placeholder distractor 2
Coding errors leading to application crashes
---
Placeholder distractor 3
Part of the garbage collection process
#### --answer--
Placeholder answer
Memory allocations which are never properly made unreachable
### --question--
#### --text--
Placeholder question
What is the main difference between `import` and `require` in JavaScript?
#### --distractors--
Placeholder distractor 1
`import` is used in Node.js, while `require` is used in the browser
---
Placeholder distractor 2
`import` supports asynchronous loading, while `require` does not
---
Placeholder distractor 3
`import` is used for CSS and image files, while `require` is used for JavaScript files
#### --answer--
Placeholder answer
`import` is part of ES6 syntax, while `require` is an older module loading syntax
### --question--
#### --text--
Placeholder question
What does `let` provide that `var` does not?
#### --distractors--
Placeholder distractor 1
Global scope
---
Placeholder distractor 2
Read-only variables
---
Placeholder distractor 3
Unlimited re-declaration
#### --answer--
Placeholder answer
Block scope
### --question--
#### --text--
Placeholder question
What is the purpose of a module bundler like Webpack or Rollup?
#### --distractors--
Placeholder distractor 1
To optimize code for performance
---
Placeholder distractor 2
It translates JavaScript code into machine language
---
Placeholder distractor 3
To format code automatically
#### --answer--
Placeholder answer
To combine multiple JavaScript modules into a single file