Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Write a function that accepts a single parameter as string and returns a string with the characters of individual words within the string being reversed. In other words, the order of words remaining intact, simply the characters that form each word should be reverse
Posted
Updated 14-Jun-12 0:41am
v2
Comments
barneyman 14-Jun-12 5:49am    
How far have you got yourself?
amperayani 14-Jun-12 6:05am    
function myfunction()
{
var txt="'hi how are you";
var n =txt.split();
strrev(n);
}
is it write? please tell me urgent
barneyman 14-Jun-12 6:31am    
on the face of it, no, but it's close ... what happens when you run it?
vino2012 14-Jun-12 5:52am    
@amperayani: you try something and post your code here.......
amperayani 14-Jun-12 6:04am    
function myfunction()
{
var txt="'hi how are you";
var n =txt.split();
strrev(n);
}
is it write?
please tell me urgent

1 solution

Try this:

JavaScript
var str = 'hi how are you';

var reversedStr = str.split("").reverse().join("");


I tested this in my Chrome JavaScript console. works fine.

Note: If it was 'please tell me urgent' kind of question, you could have Googled 'javascript reverse string' and found the answer within 10 seconds.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900