-
Notifications
You must be signed in to change notification settings - Fork 7
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
Jacob's homework for lesson 5 #2
base: master
Are you sure you want to change the base?
Conversation
@@ -31,6 +31,31 @@ console.log('Problem 1:') | |||
|
|||
// Add your code below this line | |||
|
|||
function blackJack(playerCardScore, dealerCardScore) { | |||
const cards = [playerCardScore, dealerCardScore] | |||
const less21 = cards.filter(cards => { |
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.
@jacobkelman nice approach used here
const less21 = cards.filter(cards => { | ||
return cards <= 21 | ||
}) | ||
const max = Math.max(...less21) |
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.
@jacobkelman cool use of the spread operator combined with Math.max()
to get the highest of the two values
|
||
} | ||
|
||
blackJack(19, 21) |
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.
@jacobkelman nice job, take a look an alternative approach to this problem found here
const uniqueValues = [...new Set(array)] | ||
const result = {} | ||
|
||
for (let i = 0; i < uniqueValues.length; i++) { |
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.
@jacobkelman interesting approach, however, you generally want to avoid nesting for
loops or if
statements if possible - check out an alternative approach here
@@ -136,6 +185,52 @@ console.log('Problem 3:') | |||
|
|||
// Add your code below this line | |||
|
|||
const scoreTable = { |
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.
@jacobkelman good job using an object to map the letters to their scores
be careful with your indentation here
z: 10 | ||
} | ||
|
||
function scrabbleScore(word) { |
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.
@jacobkelman this code is clear and easy to follow, good job
let count = 0 | ||
|
||
for(let i = 0; i < characters.length; i++){ | ||
if(characters[i] == characters[i+1]) |
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.
@jacobkelman be careful with the syntax for the if
statements
Including the curly braces improves the readability of your code
if (condition) {
}
Also, you should use ===
(strict comparison) instead of ==
@@ -208,6 +314,22 @@ console.log('Problem 5:') | |||
|
|||
// Add your code below this line | |||
|
|||
function doubleLetters(word) { |
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.
@jacobkelman nice approach
@jacobkelman nice work |
No description provided.