Reverse the word in a string with the same order in javascriptElegant function to “increase” a JavaScript string - for example, turning “aac” into “aad”Random weighted 'tick' functionSplit a String by an indexes arrayReturning Function Calls from an Array within a JavaScript FunctionRedacting everything in a string except a particular wordSimple string-split by root and sufix algorithmRecursive function that reverse the words in a stringProgram to reverse a string using std::stringSearch for longest substring in alphabetical order in a given stringReverse a string and change the position
What happened to Captain America in Endgame?
Single Colour Mastermind Problem
Is the 5 MB static resource size limit 5,242,880 bytes or 5,000,000 bytes?
Unexpected email from Yorkshire Bank
Is creating your own "experiment" considered cheating during a physics exam?
Sci-fi book: portals appear in London and send a failed artist towards a designated path where he operate a giant superweapon
Help to reproduce a tcolorbox with a decoration
How to figure out whether the data is sample data or population data apart from the client's information?
How come there are so many candidates for the 2020 Democratic party presidential nomination?
Do I have an "anti-research" personality?
How did Captain America manage to do this?
How would one muzzle a full grown polar bear in the 13th century?
Sci-fi novel series with instant travel between planets through gates. A river runs through the gates
Confused by chemical notation
A Note on N!
Pulling the rope with one hand is as heavy as with two hands?
Rivers without rain
What's the polite way to say "I need to urinate"?
What is the relationship between spectral sequences and obstruction theory?
(Java Minecraft 1.14) Was the Levels:n beacon tag removed/altered?
Killing undead fish underwater
Who and which - What to choose when we are referring to a choice between two or more things or persons
Mac Pro install disk keeps ejecting itself
How to get a plain text file version of a CP/M .BAS (M-BASIC) program?
Reverse the word in a string with the same order in javascript
Elegant function to “increase” a JavaScript string - for example, turning “aac” into “aad”Random weighted 'tick' functionSplit a String by an indexes arrayReturning Function Calls from an Array within a JavaScript FunctionRedacting everything in a string except a particular wordSimple string-split by root and sufix algorithmRecursive function that reverse the words in a stringProgram to reverse a string using std::stringSearch for longest substring in alphabetical order in a given stringReverse a string and change the position
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I want reverse the string with the same order. We should not use the Array functions like split(), .reverse() and some other array functions also except array.length.
Here i am attached my code. How to achieve that thing more efficiently.
var str = "i am javascript";
// result "i ma tpircsavaj"
function reverseString(myStr)
var strlen = myStr.length, result = "", reverseStr = "", reverseStrArr = [];
for(var i = strlen-1; i >= 0; i--)
reverseStr += myStr[i];
for(var j = 0; j < strlen; j++)
if(reverseStr[j] == " ")
reverseStrArr.push(result);
result = "";
else
result += reverseStr[j];
if(j + 1 == strlen)
reverseStrArr.push(result);
result = "";
for(var k=reverseStrArr.length - 1; k >= 0; k--)
result += reverseStrArr[k] + " "
console.log(result);
reverseString(str);
javascript strings
New contributor
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
I want reverse the string with the same order. We should not use the Array functions like split(), .reverse() and some other array functions also except array.length.
Here i am attached my code. How to achieve that thing more efficiently.
var str = "i am javascript";
// result "i ma tpircsavaj"
function reverseString(myStr)
var strlen = myStr.length, result = "", reverseStr = "", reverseStrArr = [];
for(var i = strlen-1; i >= 0; i--)
reverseStr += myStr[i];
for(var j = 0; j < strlen; j++)
if(reverseStr[j] == " ")
reverseStrArr.push(result);
result = "";
else
result += reverseStr[j];
if(j + 1 == strlen)
reverseStrArr.push(result);
result = "";
for(var k=reverseStrArr.length - 1; k >= 0; k--)
result += reverseStrArr[k] + " "
console.log(result);
reverseString(str);
javascript strings
New contributor
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
$begingroup$
I think you want to keep the word order, of a string, but reverse each individual word in the string? Yes, the result of your code is"i ma tpircsavaj ".
$endgroup$
– KIKO Software
2 hours ago
add a comment |
$begingroup$
I want reverse the string with the same order. We should not use the Array functions like split(), .reverse() and some other array functions also except array.length.
Here i am attached my code. How to achieve that thing more efficiently.
var str = "i am javascript";
// result "i ma tpircsavaj"
function reverseString(myStr)
var strlen = myStr.length, result = "", reverseStr = "", reverseStrArr = [];
for(var i = strlen-1; i >= 0; i--)
reverseStr += myStr[i];
for(var j = 0; j < strlen; j++)
if(reverseStr[j] == " ")
reverseStrArr.push(result);
result = "";
else
result += reverseStr[j];
if(j + 1 == strlen)
reverseStrArr.push(result);
result = "";
for(var k=reverseStrArr.length - 1; k >= 0; k--)
result += reverseStrArr[k] + " "
console.log(result);
reverseString(str);
javascript strings
New contributor
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
I want reverse the string with the same order. We should not use the Array functions like split(), .reverse() and some other array functions also except array.length.
Here i am attached my code. How to achieve that thing more efficiently.
var str = "i am javascript";
// result "i ma tpircsavaj"
function reverseString(myStr)
var strlen = myStr.length, result = "", reverseStr = "", reverseStrArr = [];
for(var i = strlen-1; i >= 0; i--)
reverseStr += myStr[i];
for(var j = 0; j < strlen; j++)
if(reverseStr[j] == " ")
reverseStrArr.push(result);
result = "";
else
result += reverseStr[j];
if(j + 1 == strlen)
reverseStrArr.push(result);
result = "";
for(var k=reverseStrArr.length - 1; k >= 0; k--)
result += reverseStrArr[k] + " "
console.log(result);
reverseString(str);
javascript strings
javascript strings
New contributor
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 3 hours ago
KallisKallis
1133
1133
New contributor
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Kallis is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$begingroup$
I think you want to keep the word order, of a string, but reverse each individual word in the string? Yes, the result of your code is"i ma tpircsavaj ".
$endgroup$
– KIKO Software
2 hours ago
add a comment |
$begingroup$
I think you want to keep the word order, of a string, but reverse each individual word in the string? Yes, the result of your code is"i ma tpircsavaj ".
$endgroup$
– KIKO Software
2 hours ago
$begingroup$
I think you want to keep the word order, of a string, but reverse each individual word in the string? Yes, the result of your code is
"i ma tpircsavaj ".$endgroup$
– KIKO Software
2 hours ago
$begingroup$
I think you want to keep the word order, of a string, but reverse each individual word in the string? Yes, the result of your code is
"i ma tpircsavaj ".$endgroup$
– KIKO Software
2 hours ago
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
I would split this into two function, simply because they do different things:
First a simple string reverser:
function reverseString(input)
var output = "";
for(var i = input.length - 1; i >= 0; i--)
output += input[i];
return output;
This is an easy function that everybody can understand. But we need to reverse words, so we make another function for that.
function reverseWords(input)
var word = "", output = "";
for(var i = input.length - 1; i >= 0; i--)
if (input[i] == " ")
output += reverseString(word) + " ";
word = "";
else
word += input[i];
output += reverseString(word);
return output;
And that's it. Now this might not be the niftiest, or shortest, solution, but it is one that reasonably easy to understand, and you get two functions for the price of one.
Also notice that there's no erroneous space at the end anymore.
$endgroup$
$begingroup$
And in two months, when someone discovers that emojis are destroyed when they are reversed, you only have a single small function that you need to repair instead of a large function. That's because the bug is clearly in thereverseStringfunction since when you callreverseString("😃"), the result is wrong withoutreverseWordsbeing involved at all.
$endgroup$
– Roland Illig
2 hours ago
$begingroup$
@RolandIllig Never thought of that, but yes, you're right. :-) :) How did you make that emoji?
$endgroup$
– KIKO Software
2 hours ago
$begingroup$
With the on-screen keyboard of my tablet.
$endgroup$
– Roland Illig
1 hour ago
$begingroup$
@RolandIllig My Windows 10 on-screen keyboard doesn't have emoji, but I can copy yours: 😃 Ah, I think this is simply an unicode character. Yes, I've got it!: 😎
$endgroup$
– KIKO Software
1 hour ago
$begingroup$
And then, one month later, another pedantic comes along and says that"AAu0308A"looks like"AÄA", but its reversed version puts the dots on one of the outer characters. And there you go, implementing all the trickery in reversing a string. The Swift programming language has these built-in, by the way. Many other programming languages lack decent string reversing support, simply because it's complicated and not needed often.
$endgroup$
– Roland Illig
1 hour ago
|
show 3 more comments
$begingroup$
:-)
Hello kallis,
Could please clarify why you don't want to put your string in an array ?
Indeed, you could use a call back function with a map method on an array of words.
The callback function would reverse each word, while keeping them at the same place in the sentence.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
let str = "I am Javascript" ;
const arrStr = (string) =>
const string2 = string.split(' ') ;
return string2 ;
let strInArray = arrStr(str) ;
strInArray = strInArray . map ( word =>
let l = word.length ;
let output = '' ;
for (var i=l-1 ; i>=0 ; i--)
output += word[i] ;
return output ;
// End of callback function
) ; // End of map method
console.log(strInArray.join(' ')) ;`
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Kallis is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f219293%2freverse-the-word-in-a-string-with-the-same-order-in-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
I would split this into two function, simply because they do different things:
First a simple string reverser:
function reverseString(input)
var output = "";
for(var i = input.length - 1; i >= 0; i--)
output += input[i];
return output;
This is an easy function that everybody can understand. But we need to reverse words, so we make another function for that.
function reverseWords(input)
var word = "", output = "";
for(var i = input.length - 1; i >= 0; i--)
if (input[i] == " ")
output += reverseString(word) + " ";
word = "";
else
word += input[i];
output += reverseString(word);
return output;
And that's it. Now this might not be the niftiest, or shortest, solution, but it is one that reasonably easy to understand, and you get two functions for the price of one.
Also notice that there's no erroneous space at the end anymore.
$endgroup$
$begingroup$
And in two months, when someone discovers that emojis are destroyed when they are reversed, you only have a single small function that you need to repair instead of a large function. That's because the bug is clearly in thereverseStringfunction since when you callreverseString("😃"), the result is wrong withoutreverseWordsbeing involved at all.
$endgroup$
– Roland Illig
2 hours ago
$begingroup$
@RolandIllig Never thought of that, but yes, you're right. :-) :) How did you make that emoji?
$endgroup$
– KIKO Software
2 hours ago
$begingroup$
With the on-screen keyboard of my tablet.
$endgroup$
– Roland Illig
1 hour ago
$begingroup$
@RolandIllig My Windows 10 on-screen keyboard doesn't have emoji, but I can copy yours: 😃 Ah, I think this is simply an unicode character. Yes, I've got it!: 😎
$endgroup$
– KIKO Software
1 hour ago
$begingroup$
And then, one month later, another pedantic comes along and says that"AAu0308A"looks like"AÄA", but its reversed version puts the dots on one of the outer characters. And there you go, implementing all the trickery in reversing a string. The Swift programming language has these built-in, by the way. Many other programming languages lack decent string reversing support, simply because it's complicated and not needed often.
$endgroup$
– Roland Illig
1 hour ago
|
show 3 more comments
$begingroup$
I would split this into two function, simply because they do different things:
First a simple string reverser:
function reverseString(input)
var output = "";
for(var i = input.length - 1; i >= 0; i--)
output += input[i];
return output;
This is an easy function that everybody can understand. But we need to reverse words, so we make another function for that.
function reverseWords(input)
var word = "", output = "";
for(var i = input.length - 1; i >= 0; i--)
if (input[i] == " ")
output += reverseString(word) + " ";
word = "";
else
word += input[i];
output += reverseString(word);
return output;
And that's it. Now this might not be the niftiest, or shortest, solution, but it is one that reasonably easy to understand, and you get two functions for the price of one.
Also notice that there's no erroneous space at the end anymore.
$endgroup$
$begingroup$
And in two months, when someone discovers that emojis are destroyed when they are reversed, you only have a single small function that you need to repair instead of a large function. That's because the bug is clearly in thereverseStringfunction since when you callreverseString("😃"), the result is wrong withoutreverseWordsbeing involved at all.
$endgroup$
– Roland Illig
2 hours ago
$begingroup$
@RolandIllig Never thought of that, but yes, you're right. :-) :) How did you make that emoji?
$endgroup$
– KIKO Software
2 hours ago
$begingroup$
With the on-screen keyboard of my tablet.
$endgroup$
– Roland Illig
1 hour ago
$begingroup$
@RolandIllig My Windows 10 on-screen keyboard doesn't have emoji, but I can copy yours: 😃 Ah, I think this is simply an unicode character. Yes, I've got it!: 😎
$endgroup$
– KIKO Software
1 hour ago
$begingroup$
And then, one month later, another pedantic comes along and says that"AAu0308A"looks like"AÄA", but its reversed version puts the dots on one of the outer characters. And there you go, implementing all the trickery in reversing a string. The Swift programming language has these built-in, by the way. Many other programming languages lack decent string reversing support, simply because it's complicated and not needed often.
$endgroup$
– Roland Illig
1 hour ago
|
show 3 more comments
$begingroup$
I would split this into two function, simply because they do different things:
First a simple string reverser:
function reverseString(input)
var output = "";
for(var i = input.length - 1; i >= 0; i--)
output += input[i];
return output;
This is an easy function that everybody can understand. But we need to reverse words, so we make another function for that.
function reverseWords(input)
var word = "", output = "";
for(var i = input.length - 1; i >= 0; i--)
if (input[i] == " ")
output += reverseString(word) + " ";
word = "";
else
word += input[i];
output += reverseString(word);
return output;
And that's it. Now this might not be the niftiest, or shortest, solution, but it is one that reasonably easy to understand, and you get two functions for the price of one.
Also notice that there's no erroneous space at the end anymore.
$endgroup$
I would split this into two function, simply because they do different things:
First a simple string reverser:
function reverseString(input)
var output = "";
for(var i = input.length - 1; i >= 0; i--)
output += input[i];
return output;
This is an easy function that everybody can understand. But we need to reverse words, so we make another function for that.
function reverseWords(input)
var word = "", output = "";
for(var i = input.length - 1; i >= 0; i--)
if (input[i] == " ")
output += reverseString(word) + " ";
word = "";
else
word += input[i];
output += reverseString(word);
return output;
And that's it. Now this might not be the niftiest, or shortest, solution, but it is one that reasonably easy to understand, and you get two functions for the price of one.
Also notice that there's no erroneous space at the end anymore.
answered 2 hours ago
KIKO SoftwareKIKO Software
2,152512
2,152512
$begingroup$
And in two months, when someone discovers that emojis are destroyed when they are reversed, you only have a single small function that you need to repair instead of a large function. That's because the bug is clearly in thereverseStringfunction since when you callreverseString("😃"), the result is wrong withoutreverseWordsbeing involved at all.
$endgroup$
– Roland Illig
2 hours ago
$begingroup$
@RolandIllig Never thought of that, but yes, you're right. :-) :) How did you make that emoji?
$endgroup$
– KIKO Software
2 hours ago
$begingroup$
With the on-screen keyboard of my tablet.
$endgroup$
– Roland Illig
1 hour ago
$begingroup$
@RolandIllig My Windows 10 on-screen keyboard doesn't have emoji, but I can copy yours: 😃 Ah, I think this is simply an unicode character. Yes, I've got it!: 😎
$endgroup$
– KIKO Software
1 hour ago
$begingroup$
And then, one month later, another pedantic comes along and says that"AAu0308A"looks like"AÄA", but its reversed version puts the dots on one of the outer characters. And there you go, implementing all the trickery in reversing a string. The Swift programming language has these built-in, by the way. Many other programming languages lack decent string reversing support, simply because it's complicated and not needed often.
$endgroup$
– Roland Illig
1 hour ago
|
show 3 more comments
$begingroup$
And in two months, when someone discovers that emojis are destroyed when they are reversed, you only have a single small function that you need to repair instead of a large function. That's because the bug is clearly in thereverseStringfunction since when you callreverseString("😃"), the result is wrong withoutreverseWordsbeing involved at all.
$endgroup$
– Roland Illig
2 hours ago
$begingroup$
@RolandIllig Never thought of that, but yes, you're right. :-) :) How did you make that emoji?
$endgroup$
– KIKO Software
2 hours ago
$begingroup$
With the on-screen keyboard of my tablet.
$endgroup$
– Roland Illig
1 hour ago
$begingroup$
@RolandIllig My Windows 10 on-screen keyboard doesn't have emoji, but I can copy yours: 😃 Ah, I think this is simply an unicode character. Yes, I've got it!: 😎
$endgroup$
– KIKO Software
1 hour ago
$begingroup$
And then, one month later, another pedantic comes along and says that"AAu0308A"looks like"AÄA", but its reversed version puts the dots on one of the outer characters. And there you go, implementing all the trickery in reversing a string. The Swift programming language has these built-in, by the way. Many other programming languages lack decent string reversing support, simply because it's complicated and not needed often.
$endgroup$
– Roland Illig
1 hour ago
$begingroup$
And in two months, when someone discovers that emojis are destroyed when they are reversed, you only have a single small function that you need to repair instead of a large function. That's because the bug is clearly in the
reverseString function since when you call reverseString("😃"), the result is wrong without reverseWords being involved at all.$endgroup$
– Roland Illig
2 hours ago
$begingroup$
And in two months, when someone discovers that emojis are destroyed when they are reversed, you only have a single small function that you need to repair instead of a large function. That's because the bug is clearly in the
reverseString function since when you call reverseString("😃"), the result is wrong without reverseWords being involved at all.$endgroup$
– Roland Illig
2 hours ago
$begingroup$
@RolandIllig Never thought of that, but yes, you're right. :-) :) How did you make that emoji?
$endgroup$
– KIKO Software
2 hours ago
$begingroup$
@RolandIllig Never thought of that, but yes, you're right. :-) :) How did you make that emoji?
$endgroup$
– KIKO Software
2 hours ago
$begingroup$
With the on-screen keyboard of my tablet.
$endgroup$
– Roland Illig
1 hour ago
$begingroup$
With the on-screen keyboard of my tablet.
$endgroup$
– Roland Illig
1 hour ago
$begingroup$
@RolandIllig My Windows 10 on-screen keyboard doesn't have emoji, but I can copy yours: 😃 Ah, I think this is simply an unicode character. Yes, I've got it!: 😎
$endgroup$
– KIKO Software
1 hour ago
$begingroup$
@RolandIllig My Windows 10 on-screen keyboard doesn't have emoji, but I can copy yours: 😃 Ah, I think this is simply an unicode character. Yes, I've got it!: 😎
$endgroup$
– KIKO Software
1 hour ago
$begingroup$
And then, one month later, another pedantic comes along and says that
"AAu0308A" looks like "AÄA", but its reversed version puts the dots on one of the outer characters. And there you go, implementing all the trickery in reversing a string. The Swift programming language has these built-in, by the way. Many other programming languages lack decent string reversing support, simply because it's complicated and not needed often.$endgroup$
– Roland Illig
1 hour ago
$begingroup$
And then, one month later, another pedantic comes along and says that
"AAu0308A" looks like "AÄA", but its reversed version puts the dots on one of the outer characters. And there you go, implementing all the trickery in reversing a string. The Swift programming language has these built-in, by the way. Many other programming languages lack decent string reversing support, simply because it's complicated and not needed often.$endgroup$
– Roland Illig
1 hour ago
|
show 3 more comments
$begingroup$
:-)
Hello kallis,
Could please clarify why you don't want to put your string in an array ?
Indeed, you could use a call back function with a map method on an array of words.
The callback function would reverse each word, while keeping them at the same place in the sentence.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
:-)
Hello kallis,
Could please clarify why you don't want to put your string in an array ?
Indeed, you could use a call back function with a map method on an array of words.
The callback function would reverse each word, while keeping them at the same place in the sentence.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
:-)
Hello kallis,
Could please clarify why you don't want to put your string in an array ?
Indeed, you could use a call back function with a map method on an array of words.
The callback function would reverse each word, while keeping them at the same place in the sentence.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
:-)
Hello kallis,
Could please clarify why you don't want to put your string in an array ?
Indeed, you could use a call back function with a map method on an array of words.
The callback function would reverse each word, while keeping them at the same place in the sentence.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 13 mins ago
SylviESylviE
11
11
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
$begingroup$
let str = "I am Javascript" ;
const arrStr = (string) =>
const string2 = string.split(' ') ;
return string2 ;
let strInArray = arrStr(str) ;
strInArray = strInArray . map ( word =>
let l = word.length ;
let output = '' ;
for (var i=l-1 ; i>=0 ; i--)
output += word[i] ;
return output ;
// End of callback function
) ; // End of map method
console.log(strInArray.join(' ')) ;`
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
let str = "I am Javascript" ;
const arrStr = (string) =>
const string2 = string.split(' ') ;
return string2 ;
let strInArray = arrStr(str) ;
strInArray = strInArray . map ( word =>
let l = word.length ;
let output = '' ;
for (var i=l-1 ; i>=0 ; i--)
output += word[i] ;
return output ;
// End of callback function
) ; // End of map method
console.log(strInArray.join(' ')) ;`
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
let str = "I am Javascript" ;
const arrStr = (string) =>
const string2 = string.split(' ') ;
return string2 ;
let strInArray = arrStr(str) ;
strInArray = strInArray . map ( word =>
let l = word.length ;
let output = '' ;
for (var i=l-1 ; i>=0 ; i--)
output += word[i] ;
return output ;
// End of callback function
) ; // End of map method
console.log(strInArray.join(' ')) ;`
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
let str = "I am Javascript" ;
const arrStr = (string) =>
const string2 = string.split(' ') ;
return string2 ;
let strInArray = arrStr(str) ;
strInArray = strInArray . map ( word =>
let l = word.length ;
let output = '' ;
for (var i=l-1 ; i>=0 ; i--)
output += word[i] ;
return output ;
// End of callback function
) ; // End of map method
console.log(strInArray.join(' ')) ;`
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 2 mins ago
SylviESylviE
11
11
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
SylviE is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
Kallis is a new contributor. Be nice, and check out our Code of Conduct.
Kallis is a new contributor. Be nice, and check out our Code of Conduct.
Kallis is a new contributor. Be nice, and check out our Code of Conduct.
Kallis is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f219293%2freverse-the-word-in-a-string-with-the-same-order-in-javascript%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
I think you want to keep the word order, of a string, but reverse each individual word in the string? Yes, the result of your code is
"i ma tpircsavaj ".$endgroup$
– KIKO Software
2 hours ago