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.
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]
3 comments
commentswe are best calgary roofing companies & Best roofing contractors calgary. Contact us for transparent quotes. roofing calgary & roofing services calgary Roofing Company in Calgary
ReplyMr Sanjay Baghela focus to reflects as the best leader of SEO in the world, and his dedication and expertise in SEO field make him enable as the owner of the best BEST SEO Expert India. You can connect with him anytime and you can see his knowledge about SEO itself. Drop your request and dial his number now!
Replybest seo expert in india
With Sanjay Baghela, your business Website is in safe hands. He and his team are the best SEO Expert in India the leading digital marketing field.
ReplyBest SEO Expert In India
Best Seo Company in India