Trying to do this challenge but have no idea how. Anyone can help?
Write a function
subLength() that takes 2 parameters, a string and a single character. The function should search the string for the two occurrences of the character and return the length between them including the 2 characters. If there are less than 2 or more than 2 occurrences of the character the function should return 0.
subLength('Saturday', 'a'); // returns 6subLength('summer', 'm'); // returns 2subLength('digitize', 'i'); // returns 0subLength('cheesecake', 'k'); // returns 0
Welcome to the Get Help category!
This is where you can ask questions about your code. Some important things to remember when posting in this category
- Learn how to ask a good question and get a good answer!
- Remember to include a link to the exercise you need help with!
- If someone answers your question, please mark their response as a solution
- Once you understand a new concept, come back and try to help someone else!