Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

julian-carvajal-gh
Copy link

Cannot auto merge I think because in my process of renaming the files I told git to also erase the originals

Copy link
Contributor

@ROgbonna1 ROgbonna1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work here, Enmanuel. Your communication is so clear. There are a couple of changes to be made. They shouldn't take long. Overall, though, great submission! 🚀

@@ -0,0 +1,53 @@
// Question 1: Looping a Triange
function triangle() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!

console.log('FizzBuzz');
} else if (i % 3 == 0) {
console.log('Fizz');
} else if (i % 5 == 0 && i % 3 != 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check for i % 3 != 0 is redundant here. If i % 3 == 0 it would have evaluated to true on line 16, line 17 would have run and the conditional would have returned.


// Question 2: FizzBuzz
function fizzBuzz() {
for (let i = 1; i <= 100; i++) {
Copy link
Contributor

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

}

// Question 3: Chess Board
function chessBoard() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this. It's so clean. The variables and parameters are so well designed. Good work!

# Problem Set 2.2 - Variables and Control Flow
## Short Response Questions

1. **What does the code below log? Why?**
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it logs this and...
Run this in the console and see what happens after the first statement is logged. Report back with what and why.

score = 100;
console.log(score, newScore);
```
This logs `100, 90` because line 1 declares `score` to be equals to `90`, line 2 declares `newScore` to be equal to `score`, line 3 reassigns `score` to be equal to `100`. When `console.log` runs, it reads `score` which was last reassigned to `100` and then reads `newScore` which still holds the value `90` because when it was declared it grasped the value of `score` and does not keep tracking any future changes to `score`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PERFECT!

let scream = greet;
console.log(scream);
```
This code doesnt log an uppercase string because while `scream` was declared and assigned `greet` after the `.toUpperCase` method, `greet` was acted upon but not *reassigned* to be the result of the operation. In order for us to see a log that is an uppercase string we can change our code to properly reassign the value of `greet`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BEAUTIFUL!


busy ? console.log(`${busy} evaluates to true`) : console.log(`${busy} evaluates to false.`);
```
This will log `'ghost evaluates to true'` and `'null evaluates to false'`. This results from the use of the ternary operator to create a conditional. `someName` is declared as `name` OR `nickname`, using the bindings as the operands of a OR binary bitwise operator which returns the truthy `‘ghost’`. `busy` is declared as `children` AND `homework`, `null && ‘lots’`, returns null. The format of a conditonal program using a ternary operator looks like conditional ? expressionOne: expressionTwo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great explanation

counter += 1;
}
```
This loop is infinite because the binding `counter` is reassigned to a value that will ensure the conditional after `while` is true every time the loop is executed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perfect!

Copy link
Contributor

@ROgbonna1 ROgbonna1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great revisions, Enmanuel! 🙏🏿

console.log('Fizz');
} else if (i % 5 == 0 && i % 3 != 0) {
} else if (i % 5 === 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great changes to this question 👍

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's it! Perfect answer!

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect! Great revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants