I want to know why my array.every is not a function, im searching for hours but i dont understand why it is not. Can someone help me ?
function controlUserInput(inputText, appLang) {
const regex = /\$[^$]*\$/gm;
const str = $('#formulaire-preview-textarea').val();
let m;
var array = populateVariable(appLang);
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
var isEqual = match.length==array.length;
for (i=0; i<=array.length-1;i++){
if(displayCpt == 4 && isEqual && match.toArray().every(function(paramInMatch){
return $.inArray(paramInMatch, array) != -1;
})){
osapi.jive.core.container.sendNotification({
"message": "Toutes les valeurs rentrées sont correctes",
"severity": "success"
});
}else{
osapi.jive.core.container.sendNotification({
"message": "Vous n'avez pas utilisé toutes les valeurs",
"severity": "error"
});
}
}
})
};
}
The .toArray()
is a jQuery object method, and as your match
is not a jQuery object, it won't work.
You could use the plain javascript Array.from(match)
.