Answer to Question #232381 in HTML/JavaScript Web Application for Suraj gajdhane

Question #232381

String Slicing

Given two strings

inputString and subString as inputs, write a JS program to slice the inputString if it includes the subString. Slice the inputString starting from the subString to the end of the inputString.


1
Expert's answer
2021-09-02T05:33:22-0400


function stringSlicing(){ 
   const string = prompt('Please input string');
   const sub = prompt('Please input sub string');
   const indexSub = string.indexOf(sub);
   if(indexSub !== -1){
      return string.slice(indexSub)
   } else {
      return string
   }
}
alert(stringSlicing());

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS