Showing posts with label javascript task. Show all posts
Showing posts with label javascript task. Show all posts

Javascript Loop particular number replace

Javascript Loop particular number replace

Hi,

Today We Discuss JavaScript how to replace particular number we create one loop that loop how to replace particular number to some string.

Javscript Loop particular number replace
JavaScript Loop particular number replace



var a = 100;
var str =[];
var ar = [];
for(var i=1;i<a;i++){
if(i.toString().indexOf('4') != -1){
   ar.push('buzz');
else {
   ar.push(i);
}
}
console.log(ar);  ////Replaced 4 number only Buzz


output

 [1, 2, 3, "buzz", 5, 6, 7, 8, 9, 10, 11, 12, 13, "buzz", 15, 16, 17, 18, 19, 20, 21, 22, 23, "buzz", 25, 26, 27, 28, 29, 30, 31, 32, 33, "buzz", 35, 36, 37, 38, 39, "buzz", "buzz", "buzz", "buzz", "buzz", "buzz", "buzz", "buzz", "buzz", "buzz", 50, 51, 52, 53, "buzz", 55, 56, 57, 58, 59, 60, 61, 62, 63, "buzz", 65, 66, 67, 68, 69, 70, 71, 72, 73, "buzz", 75, 76, 77, 78, 79, 80, 81, 82, 83, "buzz", 85, 86, 87, 88, 89, 90, 91, 92, 93, "buzz", 95, 96, 97, 98, 99]

How do you reverse a string in JavaScript?

How do you reverse a string in JavaScript?

 

string reverse print javascript
string reverse print javascript

 

Hi,

Today we discuss how to given string reverse print using javascript. blow code.

function stringprint(str){

let strpint = "";
for(let i=0;i<str.length;i++){
strpints = str[i]+ strpint;
console.log(strpints);
return strpints;



Reverse print ;

function reverseespringprint(str){
let reverstr = "";

for(let i>str.length-1;i>=0;i--){
revstr = reverstr+str[i] ;
console.log(revstr);
return revstr;
}

Books Will Give More Knowledge - Purchase Books