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

Another test & solution for #77 #100

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

Another test & solution for #77 #100

wants to merge 2 commits into from

Conversation

seemcat
Copy link
Contributor

@seemcat seemcat commented Jun 12, 2017

No description provided.

solutions/77.js Outdated
obj.consonant =+ 1;
}
console.log('obj', obj);
return obj;
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove console.log

Copy link
Contributor Author

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

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').

Copy link
Contributor Author

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;
Copy link
Collaborator

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

Copy link
Contributor Author

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! 😅

Copy link
Collaborator

@yjlim5 yjlim5 left a 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;
Copy link
Collaborator

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"', () =>{
Copy link
Collaborator

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?

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.

3 participants