-
Notifications
You must be signed in to change notification settings - Fork 12
HW3 #17
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?
HW3 #17
Conversation
| words.forEach(function (word) { | ||
| newWords.push(word.split('').join(sp)) | ||
| }); | ||
| return newWords.join(' '); |
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.
@Zorin-Alex Works good. Lok at split method deeper, it can take regexp as an argument, so you can split all the string with split(/\s|/)) and then join in one string
| function convert(object) { | ||
| var arr = [] | ||
| for (const key in object) { | ||
| arr.push([key, object[key]]); |
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.
@Zorin-Alex Works good. Also you can look at internal method Object.entries
| var splitString = str.split('-'); | ||
| var newString = []; | ||
| if (splitString.length == 1) { | ||
| splitString = str.split('_'); |
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.
@Zorin-Alex Works good. And here also you can use split with regexp
| words.forEach(function (word) { | ||
| newString.push(word.split('').reverse().join('')); | ||
| }); | ||
| return newString.join(' '); |
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.
@Zorin-Alex Works good. You can use .map method of array to handle all entries like str.split(' ').map( /* and here function from words.forEach */ )
No description provided.