-
I want to clear up some terminology.
-
JS Execution Order & the Event Loop
- Procedural
const sumOf1And1 = 1 + 1; const outputElem = document.getElementById('output'); outputElem.innerHTML = `The sum of 1 and 1 is {sumOf1And1}`;
- Conditionals
const sumOf1And1 = 1 + 1; const outputElem = document.getElementById('output'); if (sumOf1And1 === 3) { outputElem.innerHTML = ` The sum of 1 and 1 is {sumOf1And1}; math is broken 🥴. `; } else { outputElem.innerHTML = ` The sum of 1 and 1 is {sumOf1And1}; math is fine 👍. `; }
- Loops
let sumOf1And1 = 0; const outputElem = document.getElementById('output'); for (let i = 0; i < 2; i++) { sumOf1And1 = sumOf1And1 + 1; } outputElem.innerHTML = `The sum of 1 and 1 is {sumOf1And1}.`;
- Functions
function sum(a, b) { const result = a + b; return result; } const sumOf1And1 = sum(1, 1); const outputElem = document.getElementById('output'); outputElem.innerHTML = `The sum of 1 and 1 is {sumOf1And1}`;
- Events
let sumOf1And1; const calcSumBtn = document.getElementById('calc-sum'); calcSumBtn.addEventListener('click', () => sumOf1And1 = 1 + 1); const outputElem = document.getElementById('output'); outputElem.innerHTML = `The sum of 1 and 1 is {sumOf1And1}`;
- Procedural
-
Notifications
You must be signed in to change notification settings - Fork 0
musa-611-fall-2022/week7
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published