Write a JavaScript program to create a new string from a given string changing the position of first and last characters. The string length must be greater than or equal to 1.
it has to be in (HTML)
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction() {
s=prompt("Enter string");
s1=s.substr(s.length-1)+s.substr(1,s.length-2)+s.substr(0,1);
alert("After replcing "+s1);
}
</script>
</body>
</html>
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Get Answers For Free
Most questions answered within 1 hours.