Convert your sheet data into a form quiz https://github.com/lsvekis/JavaScript-Quiz-Form-Builder
1. Set up your Google Sheet
Use (or create) a spreadsheet and add a sheet (tab) named Questions.
In row 1, put these headers:
| A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|
| Question | Option A | Option B | Option C | Option D | CorrectOption | Explanation |
Then from row 2 downward, paste your 100 questions like this:
- Column A – Full question text
- Columns B–E – Answer options A–D
- Column F – Correct option letter:
A,B,C, orD - Column G – Explanation text for feedback
Example row:
| Question | Option A | Option B | Option C | Option D | CorrectOption | Explanation |
|---|---|---|---|---|---|---|
What does typeof 42 return? | “int” | “number” | “integer” | “numeric” | B | In JavaScript all numbers have type “number”. |
Do this for all 100 questions (you can copy/paste from the quiz we already wrote).
2. Add this Apps Script to build the Form from the Sheet
- In the Sheet, go to Extensions → Apps Script.
- Delete any starter code and paste this script:
/**
* Builds a Google Form quiz from the "Questions" sheet.
* Each row becomes a multiple-choice question.
*
* Sheet structure (row 1 headers):
* A: Question
* B: Option A
* C: Option B
* D: Option C
* E: Option D
* F: CorrectOption (A/B/C/D)
* G: Explanation (shown as feedback)
*/
function buildJavaScriptQuizFormFromSheet() {
const SHEET_NAME = 'Questions';
const formTitle = 'JavaScript 100-Question Quiz';
// Get sheet
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sheet = ss.getSheetByName(SHEET_NAME);
if (!sheet) {
throw new Error('Sheet named "' + SHEET_NAME + '" not found.');
}
const lastRow = sheet.getLastRow();
if (lastRow < 2) {
throw new Error('No question data found. Make sure you have rows starting from row 2.');
}
// Get all data (excluding header row)
const values = sheet.getRange(2, 1, lastRow - 1, 7).getValues();
// [ [Question, A, B, C, D, Correct, Explanation], ... ]
// Create the Form as a quiz
const form = FormApp.create(formTitle)
.setDescription('JavaScript multiple-choice quiz generated from a Google Sheet.')
.setIsQuiz(true);
values.forEach(function (row, index) {
const questionText = row[0];
const optionA = row[1];
const optionB = row[2];
const optionC = row[3];
const optionD = row[4];
const correctLetter = String(row[5] || '').trim().toUpperCase();
const explanation = row[6] || '';
if (!questionText || !optionA || !optionB || !optionC || !optionD || !correctLetter) {
// Skip incomplete rows
return;
}
// Determine correct index (0–3) based on letter
const letters = ['A', 'B', 'C', 'D'];
const correctIndex = letters.indexOf(correctLetter);
if (correctIndex === -1) {
// Skip if invalid letter
return;
}
// Create a multiple-choice item
const item = form.addMultipleChoiceItem();
item.setTitle((index + 1) + '. ' + questionText)
.setPoints(1);
const optionTexts = [optionA, optionB, optionC, optionD];
const choices = optionTexts.map(function (text, i) {
return item.createChoice(text, i === correctIndex);
});
item.setChoices(choices);
// Feedback (optional but nice)
if (explanation) {
const correctFb = FormApp.createFeedback()
.setText('Correct: ' + explanation)
.build();
const incorrectFb = FormApp.createFeedback()
.setText('Review: ' + explanation)
.build();
item.setFeedbackForCorrect(correctFb);
item.setFeedbackForIncorrect(incorrectFb);
}
});
Logger.log('Form created!');
Logger.log('Edit URL: ' + form.getEditUrl());
Logger.log('Live URL: ' + form.getPublishedUrl());
}
/**
* (Optional) Helper: creates the header row template on the "Questions" sheet.
* Run this once if you want the script to add headers for you.
*/
function createQuestionsSheetTemplate() {
const SHEET_NAME = 'Questions';
const ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheetByName(SHEET_NAME);
if (!sheet) {
sheet = ss.insertSheet(SHEET_NAME);
}
sheet.clear();
sheet.getRange(1, 1, 1, 7).setValues([[
'Question',
'Option A',
'Option B',
'Option C',
'Option D',
'CorrectOption (A/B/C/D)',
'Explanation'
]]);
SpreadsheetApp.flush();
}
3. How to use it
- In the Script Editor, run
createQuestionsSheetTemplate()once if you want it to add the header row automatically. - Paste your 100 questions + options + correct letter + explanation into the
Questionssheet under those headers. - Run
buildJavaScriptQuizFormFromSheet(). - Open View → Logs to grab:
- Edit URL – to edit the quiz
Ready-to-use CSV template (with all 100 JavaScript questions) that you can paste into a text file and import into Google Sheets, or just paste directly into a blank Sheet (Sheets will auto-split into columns).
Columns:
Question, Option A, Option B, Option C, Option D, CorrectOption, Explanation
"Question","Option A","Option B","Option C","Option D","CorrectOption","Explanation"
"What does typeof 42 return?","int","number","integer","numeric","B","In JavaScript all numeric values, integers and floats, share the type number."
"What is the result of typeof null?","null","undefined","object","value","C","typeof null returns object due to a long standing historical quirk."
"What will console.log(1 + '2') output?","3","3 as a string","12","NaN","C","Adding a number and a string causes string concatenation, producing 12."
"What does NaN stand for?","Not a Null","Not a Number","Negative a Number","No actual Number","B","NaN represents an invalid numeric result, such as 0 divided by 0."
"Which of these is NOT a primitive type in JavaScript?","string","boolean","object","symbol","C","object is not primitive, while string, boolean and symbol are primitives."
"What will typeof undefined return?","null","undefined","object","void","B","The primitive value undefined has the type undefined."
"Which operator is used for strict equality comparison?","==","=","===","=>","C","=== compares both value and type with no coercion."
"What is the result of '5' == 5?","true","false","NaN","Throws an error","A","== performs type coercion, converting the string 5 to number 5 so the comparison is true."
"What is the result of '5' === 5?","true","false","NaN","Throws an error","B","=== compares value and type, a string is not strictly equal to a number."
"Which keyword declares a block scoped variable?","var","let","const","Both let and const","D","Both let and const create block scoped bindings, while var is function scoped."
"What happens if you access a variable declared with let before its declaration?","Returns undefined","Throws a ReferenceError","Returns null","Returns an empty string","B","let and const are in the temporal dead zone before declaration and cause a ReferenceError if accessed."
"What will console.log(a); var a = 10; log?","10","undefined","null","ReferenceError","B","var is hoisted and initialized with undefined, so the log shows undefined."
"What will console.log(b); let b = 10; log?","10","undefined","null","ReferenceError","D","Accessing a let binding before declaration throws a ReferenceError."
"What is a closure?","A way to close open files","A function bundled with its lexical environment","A function that always returns another function","A method to end a program","B","A closure is when a function retains access to variables from its outer scope even after that scope has finished."
"Which array method adds one or more elements to the end of an array?","push","pop","shift","unshift","A","push adds elements to the end of an array."
"Which array method creates a new array without modifying the original?","push","splice","slice","pop","C","slice returns a new array and does not mutate the original."
"What is the result of [1, 2, 3].length?","2","3","4","undefined","B","The length property of this array is 3."
"Which method converts a JSON string into an object?","JSON.encode","JSON.parse","JSON.stringify","JSON.toObject","B","JSON.parse converts a JSON string into a JavaScript object."
"What is the output of console.log(0 == false)?","true","false","NaN","Throws error","A","== coerces false to 0, so 0 == false is true."
"What is the output of console.log(0 === false)?","true","false","NaN","Throws error","B","Strict equality compares type and value, 0 and false have different types."
"How do you write an arrow function that returns the square of x?","x => { x * x }","x => x * x","(x) => return x * x","x -> x * x","B","A single expression arrow function can omit braces and return keyword."
"What will console.log(typeof (() => {})) output?","function","object","arrow","undefined","A","Arrow functions are still functions, so typeof returns function."
"What does Array.isArray(value) do?","Checks if value is iterable","Checks if value is an array","Checks if value is an object","Converts value to an array","B","Array.isArray returns true only when the value is an array."
"What is the value of Number('hello')?","hello","NaN","0","undefined","B","Converting a non numeric string to a number results in NaN."
"Which of these is falsy?","'0'","[]","{}","","D","The empty string is falsy, the others are truthy."
"Which keyword stops a loop immediately?","exit","stop","break","return","C","break exits the nearest loop or switch statement."
"Which keyword skips the current iteration of a loop and continues with the next?","skip","next","continue","pass","C","continue ends the current iteration and proceeds with the next one."
"What is the result of console.log('5' - 2)?","52","3","NaN","3 as a string","B","The minus operator coerces strings to numbers, so '5' - 2 becomes 3."
"What is the result of console.log('5' + 2)?","52","7","NaN","7 as a string","A","With a string operand, plus does concatenation, producing 52."
"In a browser, what is window?","A built in array","The global object for browser JavaScript","A reserved DOM name","A CSS object","B","window represents the global scope in browsers."
"In strict mode, what happens if you assign to an undeclared variable?","It creates a global variable","It creates a local variable","It throws a ReferenceError","It is silently ignored","C","Strict mode forbids implicit globals and throws a ReferenceError."
"How do you enable strict mode in a script file?","enable strict;","'use strict'; at the top","use strict; without quotes","strict_mode(true);","B","The directive 'use strict'; at the top of a file or function enables strict mode."
"What is the output of console.log([] == false)?","true","false","NaN","Throws error","A","[] is coerced to empty string then to 0, false also becomes 0 so the comparison is true."
"What is the value of typeof NaN?","nan","number","undefined","object","B","NaN is still a numeric value so typeof returns number."
"How do you check if a value is NaN without coercion?","value == NaN","value === NaN","isNaN(value)","Number.isNaN(value)","D","Number.isNaN checks specifically for NaN and does not coerce the argument."
"What is the result of console.log([] + [])?","[]","","'[]'","NaN","B","Arrays are converted to strings, an empty array becomes an empty string and concatenating two gives empty string."
"What does Array.prototype.map return?","A new array","The modified original array","A number","An object","A","map returns a new array, leaving the original unchanged."
"Which method is best for selecting elements that meet a condition?","forEach","map","filter","reduce","C","filter returns a new array containing only elements for which the callback returns true."
"What does Array.prototype.forEach return?","A new array","The original array","undefined","The number of iterations","C","forEach is for side effects and always returns undefined."
"What does Array.prototype.reduce typically do?","Sorts an array","Flattens arrays only","Reduces an array to a single value","Filters elements","C","reduce accumulates results into a single output value."
"Which operator spreads the elements of an iterable?","...","*","&","=>","A","The spread syntax ... expands elements of an iterable."
"What is destructuring in JavaScript?","Removing properties from objects","Assigning values from objects or arrays into variables","Deleting variables","Breaking a loop","B","Destructuring lets you extract values from arrays or objects into variables using pattern syntax."
"Which is valid array destructuring?","let {a, b} = [1, 2];","let [a, b] = [1, 2];","let (a, b) = [1, 2];","let [a: 1, b: 2];","B","Array destructuring uses square brackets, for example let [a, b] = [1, 2]."
"Which is valid object destructuring?","let [name] = { name: 'Max' };","let {name} = { name: 'Max' };","let (name) = { name: 'Max' };","let {name: 'Max'};","B","Object destructuring uses curly braces with property names, for example let {name} = obj."
"In non strict mode, what is the default value of this inside a regular function call fn() in a browser?","undefined","The global object window","The function itself","null","B","In non strict mode, a plain function call binds this to the global object window."
"In an arrow function, this is:","Dynamically bound","Always window","Lexically inherited from the surrounding scope","Always undefined","C","Arrow functions capture this from the enclosing lexical scope rather than having their own."
"How do you create a new object using a constructor function Person?","Person()","new Person()","create Person()","Object(Person)","B","The new keyword constructs a new object and calls Person as a constructor."
"Which prototype is used when calling a method on an array literal like []?","Object.prototype","Array.prototype","Function.prototype","Prototype.prototype","B","Arrays inherit their methods from Array.prototype."
"What does Object.create(proto) do?","Copies all properties deeply from proto","Creates an object whose internal prototype is proto","Clones proto and adds methods","Creates a new class from proto","B","Object.create returns a new object whose prototype is the given proto."
"How do you define a class in modern JavaScript?","class Person {}","function class Person {}","Person class {}","new class Person {}","A","ES6 introduced the class syntax class Person {}."
"How do you define a method inside a class?","methodName: function() {}","function methodName() {}","methodName() {}","let methodName() {}","C","Inside a class body, methods are defined as methodName() {} without the function keyword."
"How do you create a subclass from a class Parent?","class Child: Parent {}","class Child extends Parent {}","class Child inherits Parent {}","class Child Parent {}","B","Child extends Parent is the ES6 syntax for inheritance."
"Which keyword calls the parent class constructor?","this()","parent()","base()","super()","D","super calls the constructor of the parent class."
"What does typeof function() {} return?","object","function","callable","method","B","Regular functions have type function when checked with typeof."
"Which statement about promises is true?","A promise can be pending, fulfilled or rejected","A promise can only be fulfilled","Promises block the main thread","Promises replace all callbacks","A","Promises represent async operations with states pending, fulfilled and rejected."
"What does Promise.resolve(5) create?","A rejected promise with value 5","A fulfilled promise with value 5","A pending promise with value 5","A synchronous value 5 only","B","Promise.resolve returns a promise immediately fulfilled with the given value."
"How do you attach a success handler to a promise p?","p.then(onFulfilled)","p.success(onFulfilled)","p.done(onFulfilled)","p.resolve(onFulfilled)","A","then registers a handler for when the promise is fulfilled."
"How do you handle errors in a promise chain?","With try catch only","With .catch()","With .error()","With .fail()","B","catch handles rejected promises and errors thrown in previous then handlers."
"Which keyword is used to declare an asynchronous function?","sync","await","async","defer","C","Prefixing a function with async makes it return a promise and allows await inside."
"What does await do inside an async function?","Pauses the whole program","Pauses only that async function until the promise settles","Converts a promise to a callback","Makes the function synchronous","B","await suspends the async function until the promise resolves or rejects, without blocking the event loop."
"What happens if an error is thrown inside an async function?","It crashes the browser","It becomes a rejected promise","It is ignored","It becomes a fulfilled promise","B","Errors in async functions reject the returned promise."
"What does setTimeout(fn, 0) do?","Executes fn immediately","Schedules fn after the current call stack clears","Blocks execution until fn completes","Throws an error","B","setTimeout with zero delay queues fn to run after the current stack and microtasks."
"Which of these is NOT part of the JavaScript language itself but provided by the browser?","Array","Promise","document","Object","C","document is part of the DOM API provided by browsers, not core JavaScript."
"How do you select an element with id main in the DOM?","document.getElement('main')","document.getElementById('main')","document.query('#main')","document.id('main')","B","getElementById selects the element whose id matches the given string."
"Which method selects the first element matching a CSS selector?","document.querySelector","document.querySelectorAll()[0] only","document.getElementBySelector","document.selectFirst","A","querySelector returns the first element that matches the selector."
"How do you add a click event listener to a button element btn?","btn.on('click', fn)","btn.click(fn)","btn.addEventListener('click', fn)","btn.addClick(fn)","C","addEventListener is the standard way to attach event listeners."
"What will document.querySelectorAll('.item') return?","A single element","An array","A NodeList","A string","C","querySelectorAll returns a NodeList, an array like collection of elements."
"Which property changes the text inside an element?","innerText","text","content","valueText","A","innerText or textContent sets the visible text content of an element."
"How do you prevent a form default submit behavior in an event handler?","event.stop()","event.preventDefault()","event.cancel()","event.stopPropagation()","B","preventDefault stops the default browser action such as submitting a form."
"What does event.stopPropagation() do?","Prevents default browser behavior","Stops the event from bubbling up to parents","Disables all event listeners","Cancels form submission only","B","stopPropagation prevents the event from propagating to ancestor elements."
"What is hoisting?","Moving files to the top of a project","JavaScript moving declarations to the top of their scope before execution","Sorting variables alphabetically","Loading external scripts earlier","B","Declarations appear to be moved to the top of their scope, this is called hoisting."
"Which are hoisted with their full definitions?","Function declarations","Function expressions","Arrow functions","Both function expressions and arrow functions","A","Function declarations are hoisted entirely and can be called before their definition."
"What is the output of console.log(hoisted()); function hoisted() { return 'Hello'; }","Hello","undefined","Error","null","A","The function declaration is hoisted so it can be called before its appearance in code."
"What is the output of console.log(x); let x = 5;","5","undefined","null","ReferenceError","D","Accessing a let binding before declaration throws a ReferenceError."
"Which method checks if an array includes a certain value?","arr.contains(value)","arr.has(value)","arr.includes(value)","arr.exists(value)","C","includes returns true if the array contains the specified value."
"Which statement about const is true?","const variables cannot be changed at all","const prevents reassignment of the binding but object contents can still change","const makes values deeply immutable","const is function scoped","B","const fixes the binding, but referenced objects and arrays remain mutable."
"What is the output of const obj = { a: 1 }; obj.a = 2; console.log(obj.a);","1","2","Error","undefined","B","The object referenced by obj is mutable so a can be updated to 2."
"What is a template literal?","A precompiled string","A string defined with backticks that can include expressions with ${}","A JSON template","A string used only for HTML","B","Template literals use backticks and support interpolation and multiline strings."
"Which is a valid template literal?","'Hello ${name}'","\"Hello ${name}\"","`Hello ${name}`","Hello ${name}","C","Interpolation with ${} only works inside backtick strings."
"How do you export a named function in ES modules?","module.export function myFunc() {}","export function myFunc() {}","exports.myFunc = function() {} in browser modules","export: myFunc()","B","Named exports use export before the declaration."
"How do you import a named function myFunc from ./utils.js?","import { myFunc } from './utils.js';","require('./utils.js').myFunc; in browser modules","import myFunc from './utils.js'; only","include myFunc from './utils.js';","A","Named imports use curly braces around the exported name."
"What is the default export import syntax?","import { default } from './mod.js';","import * as default from './mod.js';","import something from './mod.js';","import default('./mod.js');","C","import something from './mod.js'; imports the module default export as something."
"Which tool checks whether a property exists directly on an object, not its prototype chain?","in operator","obj.hasOwnProperty('prop')","obj.propertyExists('prop')","Object.exists(obj, 'prop')","B","hasOwnProperty returns true only for an object's own properties."
"What is the result of const a = { x: 1 }; const b = a; b.x = 2; console.log(a.x);","1","2","undefined","Error","B","a and b refer to the same object, so changing b.x also changes a.x."
"How do you make a shallow copy of an object obj?","const copy = obj;","const copy = Object.copy(obj);","const copy = { ...obj };","const copy = new obj();","C","The spread operator copies own enumerable properties into a new object."
"What is event delegation?","Assigning one event to many elements","Attaching a single listener to a parent to handle events from children","Delegating events from browser to server","Combining multiple events into one","B","Event delegation uses bubbling so a parent handler can manage events for many child elements."
"Which built in data structure maintains insertion order and uses key value pairs with any key type?","Object","Map","Set","Array","B","Map allows keys of any type and preserves insertion order."
"Which structure holds unique values only, no duplicates?","Array","Map","Set","Object","C","Set stores unique values and ignores duplicate adds."
"What does 'use strict' mainly help with?","Faster network requests","Cleaner syntax highlighting","Catching common mistakes and unsafe actions","Making code run in parallel","C","Strict mode throws errors for unsafe actions like implicit globals."
"What does Symbol() create?","A unique immutable value usable as an object key","A string alias","A new numeric type","A private variable","A","Symbols are unique immutable primitive values often used as property keys."
"What is the main difference between == and ===?","=== compares only types","== compares only values","=== compares value and type without coercion","They are identical","C","=== performs strict equality with no type coercion, == allows coercion."
"What does Object.freeze(obj) do?","Prevents adding, removing or changing properties of obj","Prevents only adding new properties","Prevents only deleting properties","Makes deep immutable copies","A","A frozen object cannot have its properties added, removed or changed, though this is shallow."
"What is the output of console.log(typeof [].constructor)?","array","object","function","constructor","C","[].constructor is Array, which is a function, so typeof returns function."
"What does Object.keys(obj) return?","All values of obj","An array of own enumerable property names","Prototype chain keys","A map of entries","B","Object.keys returns an array of the object's own enumerable property names."
"What is the main difference between for...in and for...of?","for...in iterates values, for...of keys","for...in iterates keys, for...of iterates values of iterables","They are identical","for...of only works on plain objects","B","for...in loops over property names, for...of iterates values of iterables like arrays and strings."
"What will console.log('2' * '3') log?","23","6","NaN","6 as a string","B","The multiply operator coerces both strings to numbers, so the result is 6."
"What is the output of console.log(Boolean('false'))?","true","false","NaN","Error","A","Any non empty string is truthy, even the text false."
"What is function currying?","Combining two functions into one","Transforming a multi argument function into a series of unary functions","Removing parameters from a function","Overriding built in functions","B","Currying turns f(a, b, c) into f(a)(b)(c), enabling partial application."
"What is the main purpose of JavaScript in web development?","Styling web pages","Structuring content","Adding interactivity and dynamic behavior","Serving pages from the server","C","JavaScript adds logic, interactivity and dynamic updates to web pages."
You can:
- Copy everything inside the
csvblock. - Paste into a blank file and save as
javascript_quiz.csv, then File → Import in Google Sheets.
OR just paste directly into a new Sheet (starting at A1) and Sheets will auto-split it.
It already matches the script’s expected columns, so you can run your buildJavaScriptQuizFormFromSheet() function right away to build the Form quiz.
