[Vuejs]-Check if array values is a substring of a string

2👍

Yes, you can use String.prototype.includes() and Array.prototype.find() to find your required string

    let arr = ['welcome', 'answer', 'question']
    let str = 'welcome001';
    const result = arr.find(item => str.includes(item));
    
    console.log(result);

Leave a comment