-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enmanuel-delanuez submission #6
base: master
Are you sure you want to change the base?
Changes from 2 commits
5ef321e
d2ec262
ba61034
b3abc27
a5e7ef0
575b377
1d8e715
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,11 @@ function triangle() { | |
// Question 2: FizzBuzz | ||
function fizzBuzz() { | ||
for (let i = 1; i <= 100; i++) { | ||
if (i % 3 == 0 && i % 5 == 0) { | ||
if (i % 3 === 0 && i % 5 === 0) { | ||
console.log('FizzBuzz'); | ||
} else if (i % 3 == 0) { | ||
} else if (i % 3 === 0) { | ||
console.log('Fizz'); | ||
} else if (i % 5 == 0 && i % 3 != 0) { | ||
} else if (i % 5 === 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great changes to this question 👍 |
||
console.log('Buzz'); | ||
} else { | ||
console.log(i); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,12 @@ | |
|
||
1. **What does the code below log? Why?** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You got rid of the brackets from the original version but I want them in there. This is what the question originally looked like: {
let singer = 'Omar Apollo';
}
console.log(`My favorite singer is ${singer}); Those brackets are important for this question. |
||
```javascript | ||
let singer = 'Omar Apollo'; | ||
{ | ||
let singer = 'Omar Apollo'; | ||
} | ||
console.log(`My favorite singer is ${singer}`); | ||
``` | ||
This logs `'My favorite singer is Omar Apollo'` because the use of `${}` interpolates the value of a binding into the string. | ||
This logs `ReferenceError: singer is not defined` because `console.log()` is looking for the variable `singer` in its global scope and cannot see it because it has a block scope. This is also supported by the keyword `let`, whereas the keyword `var` has a global or function scope. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's it! Perfect answer! |
||
|
||
2. **What happens when we run the following code? Why?** | ||
```javascript | ||
|
@@ -16,7 +18,7 @@ | |
favorite = 'Maya'; | ||
console.log(`Actually, ${favorite} is my favorite.`); | ||
``` | ||
This logs `'Our favorite Marcy Lab family member is Juan Pablo'` because the binding `favorite` was declared with the keyword `const`, meaning it is a constant that can't be reassigned. | ||
This logs `'Our favorite Marcy Lab family member is Juan Pablo'`. After, it logs a `TypeError` because the binding `favorite` was declared with the keyword `const` and we tried to reassign it before the second log which is not allowed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect! Great revision. |
||
|
||
3. **What does the following code log? Why?** | ||
```javascript | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're using non-strict equality here (
==
instead of===
). Since you're dealing with numbers only, it shouldn't be an issue but it is still good practice to always use strict equality comparisons