0

I have a var called title, that I am using in a rest driven search query. The search works, but it only filters if the word matches exactly what the title has. The issue is that sometimes the search may be close or have part of the title, I am trying to using split to break up the title-maybe if the first 3 letters of the word matches or if title matches. How can I extend my code to accommodate this?

I tried using "split" but

var Title = $(#txtSkill").val();
var res = Title.split("");

1 Answer 1

3

Title.split("") will split the string into an array of individual letters like ["v","a","l","u","e"]

What you want here is substring() which will:

extract characters from indexStart up to but not including indexEnd.

var Title = $("#txtSkill").val(); 
var res = Title.substring(0,3);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.