Write the below code to use HTML and
JavaScript.
1)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.
2)Write a JavaScript program to check whether a string starts with
'Java' and false otherwise
<!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+"\n"+s+" starts with Java
"+s.startsWith("Java"));
}
</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.