Skip to content
Advertisement

How to compose JS functions with condition check at each step?

I have written my code

JavaScript

The goal is to check that the first charachter is ( and the last ). Works OK.

JavaScript

Now, the next step would be the high-order function that would include removing first and last character at each step and checking if the condition is met again.

JavaScript

String befor and after this step.

JavaScript

How to do this?

Advertisement

Answer

You could check for length and if the string starts and ends with wanted characters and the rest fullfills the same objective.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement