-
Notifications
You must be signed in to change notification settings - Fork 39
completed final assessment #52
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,11 @@ | |
| * ex: isOdd(75); // true | ||
| */ | ||
|
|
||
| function isOdd() { | ||
|
|
||
| function isOdd(n) { | ||
| if (n % 2 === 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. How can you use a ternary operator here? |
||
| return false | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| module.exports = isOdd | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,13 @@ | |
| */ | ||
|
|
||
| function numberOfDigits() { | ||
|
|
||
| function numberOfDigits(n) { | ||
| let count = 0 | ||
| let num = n.toString() | ||
| for (let i of num) { | ||
| count += 1 | ||
|
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. What is a property that strings have which provides us with the number of characters in the string? You can use this property in place of the for loop. |
||
| } | ||
| return count | ||
| } | ||
|
|
||
| module.exports = numberOfDigits | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,8 +11,17 @@ | |
| * 17 is also replaced with 'BOOM' because it contains a 7. | ||
| */ | ||
|
|
||
| function sevenBoom() { | ||
|
|
||
| function sevenBoom(n) { | ||
| let newArr = [] | ||
| for (let i = 1; i <= n; i += 1) { | ||
| if (i % 7 === 0 || i % 10 === 7) { | ||
|
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. Consider numbers 70-79; will they be 'BOOM' based on this function? How can you find any number that contains a 7 in any digit? |
||
| newArr.push('BOOM') | ||
| } | ||
| else { | ||
| newArr.push(i) | ||
| } | ||
| } | ||
| return newArr | ||
| } | ||
|
|
||
| module.exports = sevenBoom | ||
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.
Since .map() returns an array, can you write this function so that you don't need newArr?