Answer to Question #220697 in HTML/JavaScript Web Application for Siva

Question #220697

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.Input

  • The first line of input contains a string inputString
  • The second line of input contains a string subString

Output

  • The output should be a sliced string or inputString (if the inputString does not include the subString)

Sample Input 1

JavaScript

S

Sample Output 1

Script

Sample Input 2

Language

air

Sample Output 2

Language



1
Expert's answer
2021-07-28T06:07:23-0400
function Slicer(param1,param2){
      if(param1.includes(param2)){
          let index = param1.indexOf(param2);
          
          console.log(param1.slice(index));
      }else{
            console.log(param1);
      }
     
}
Slicer("Javascript","s");
//output - script
//Slicer("Language","air");
//output - Language

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