Jscodes
Jscodes
Write a JavaScript that accepts a string and searches for the pattern “MSBTE” in the
given string. If the pattern is found, JavaScript will display that “Pattern is found” else
<script>
if(a.match("MSBTE"))
document.write("Pattern is found");
else
</script>
2. Write a Java script that will replace following specified value with another value in a
<script>
document.write(a.replace("fail","pass"));
</script>
3. Write JavaScript code to perform following operations on string. (Use split() method)
<html>
<body>
<script>
document.write("First name:"+b[0]+"<br>");
document.write("Middle name:"+b[1]+"<br>");
document.write("Last name:"+b[2]);
</script>
</body>
</html>
4. Write a javascript function that accepts a string as a parameter and find the length of
the string.
<script>
function no(a)
document.write(a.length);
</script>
<script>
function checkPalindrome(string) {
document.write(value);
</script>
6. Write a javascript function to generate Fibonacci series till user defined limit.
<script>
var n1 = 0, n2 = 1, next_num, i;
var num = parseInt (prompt (" Enter the limit for Fibonacci Series "));
next_num = n1 + n2;
n1 = n2;
n2 = next_num;
</script>
let b="aeiouAEIOU";
let count=0,char,char1;
for(let i=0;i<a.length;i++)
char=a[i];
char1=b[j];
if(char==char1)
count=count+1;
</script>
8. Write a JavaScript that find and displays number of duplicate values in an array.
let a=["a","b","c","d","e"];
let b=["z","c","y","x","a"];
let c=[];
let count=0,char,char1;
for(let i=0;i<a.length;i++)
char=a[i];
for(let j=0;j<b.length;j++)
char1=b[j];
if(char==char1)
count++;
c.push(char1);
9. Develop JavaScript to convert the given character to Unicode and vice versa.
<script>
document.write(character);
let character1="A";
document.write("<br>"+unicodeValue1);
</script>
10. Write a JavaScript function to insert a string within a string at a particular position.
<script>
let pos = 3;
</script>