I have an enum
enum YourEnum {
enum1 = 'Sunday',
enum2 = 'Monday',
enum3 = 'Tuesday',
}
and I want to check if some part of word are included in. If for example user tips "mon", i'm expecting that it matches with Monday.
I have two problems: I need to convert values of enum in lowercase, and I need that part of word match.
I tried to do that:
var value = "mon";
if (Object.values(YourEnum).toString().toLowerCase().includes((value))) {
console.log("some values match")
}
or
const list=Object.values(YourEnum).toString().toLowerCase();
for (let i = 0; i < list.length; i++){
if (list[i].indexOf("mon") >= 0){
console.log("some values match", list[i]);
}
}
But I don't get the results I'm expecting.
Any ideas ?