// https://lodash.com/
// var _ = require('lodash');
function checkIfContains(check, value){
if(_.isUndefined(check) || _.isNull(check)){
return false;
}
if(_.isObject(check)){
var flag = false;
Object.keys(check).forEach(function(key){
if(checkIfContains(check[key], value)){
flag = true;
}
});
return flag;
}
if(_.isNumber(check)){
check = String(check);
} else if(_.isString(check)){
check = check.toLowerCase();
}
return _.includes(check, value);
}
//----------------------------------------------------------------------------//
console.log(checkIfContains('aloha', 'al')); // true
console.log(checkIfContains('aloha', 'test')); // false
console.log(checkIfContains({att1: 'aloha', att2: 'ula ula'}, 'ula')); // true
console.log(checkIfContains({att1: 'aloha', att2: 'ula ula'}, 'test')); // false
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.