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

Jacob's homework for lesson 5 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jacobkelman
Copy link

No description provided.

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

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

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

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++) {
Copy link
Contributor

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 = {
Copy link
Contributor

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) {
Copy link
Contributor

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])
Copy link
Contributor

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) {
Copy link
Contributor

@kareemgrant kareemgrant Nov 2, 2019

Choose a reason for hiding this comment

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

@jacobkelman nice approach

@kareemgrant
Copy link
Contributor

@jacobkelman nice work

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

Successfully merging this pull request may close these issues.

2 participants