-
Notifications
You must be signed in to change notification settings - Fork 24
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
Another test & solution for #77 #100
base: master
Are you sure you want to change the base?
Conversation
solutions/77.js
Outdated
obj.consonant =+ 1; | ||
} | ||
console.log('obj', obj); | ||
return obj; |
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.
remove console.log
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.
Resolved!
solutions/77.js
Outdated
let i = 0; | ||
let obj = {}; | ||
while (i < string.length){ | ||
if (string[i] === 'a' || 'e' || 'i' || 'o' || 'u'){ |
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.
Did you test your solution? I don't think this if condition would work: if (string[i] === 'a' || 'e' || 'i' || 'o' || 'u')
.
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 right, it was wrong! I just fixed it 😸
solutions/77.js
Outdated
let obj = {}; | ||
while (i < string.length){ | ||
if (string[i] === 'a' || 'e' || 'i' || 'o' || 'u'){ | ||
obj.vowel =+ 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.
This operator also =+
would not work. Make sure to run npm run test
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.
Yes, I just fixed it! 😅
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.
Address all comments made by reviewers first please.
module.exports = {solution}; | ||
const solution1 = (string) =>{ | ||
let i = 0; | ||
let j = 0; |
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.
This is a working solution. Good start! Now try to implement this solution without using extra variables j
and k
. Hint: initialize obj
before entering the while loop.
it('should return { vowel: 3, consonant: 4 } for "goodbye"', () =>{ | ||
expect(solution1('goodbye')).to.eql({vowel: 3, consonant: 4 }); | ||
}); | ||
it('should return { vowel: 2, consonant: 3 } for "bonzo"', () =>{ |
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.
Can we replace this test case with a different scenario - like a word without 0 vowel or 0 constant?
No description provided.