|
We have to create a program that first, accepts a string from the user (up to 80 words, then, it acts the user the choose which word they want to replace in that string, and finally, they have to write in the string to REPLACE IT WITH.
I need the return method.
return (str,str,str)
HELP PLESE :(
|
|
|
Hello mike31
Try this code
<HTML>
<HEAD>
<TITLE>String Replace Code</TITLE>
<script type="text/javascript">
var retStr=new Array(3);
function replace(string,text,by)
{
var myString=string;
while(myString.indexOf(text)!=-1)
{
myString=myString.replace(text,by);
}
retStr[0]=myString;
retStr[1]=text;
retStr[2]=by;
return retStr;
}
var strMsg='You want to Replace XX with AB in string ABCDAB';
strMsg=strMsg+'\nYou can use replace("ABCDAB","AB","XX")';
strMsg=strMsg+"You get Value "+replace("ABCDAB","AB","XX");
strMsg=strMsg+"\nYour Replaced String "+replace("ABCDAB","AB","XX")[0];
document.write(strMsg);
</script>
</HEAD>
<BODY>
</BODY>
</HTML>
|
|
|
|
|
|
|
|