Skip to content

Conversation

@Zorin-Alex
Copy link

No description provided.

words.forEach(function (word) {
newWords.push(word.split('').join(sp))
});
return newWords.join(' ');
Copy link
Contributor

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

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('_');
Copy link
Contributor

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

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 */ )

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.

2 participants