Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,041 questions

40,764 answers

573 users

How to remove N characters from a string by index in JavaScript

Learn & Practice SQL


76 views
asked Jun 20, 2020 by avibootz
edited Jun 20, 2020 by avibootz

1 Answer

0 votes
function removeNAt(s, i, n) {
    return s.slice(0, i) + s.slice(i + n);
}
   
let s = "javascript php c++";

idx = 3
   
s = removeNAt(s, idx, 4);
   
console.log(s);
  
  
  
   
/*
run:
   
javipt php c++
  
*/

 





answered Jun 20, 2020 by avibootz
edited Jun 21, 2020 by avibootz

Related questions

1 answer 72 views
2 answers 112 views
1 answer 68 views
1 answer 76 views
...