Example: Dota is better than league of legends (true).
Counter Strike is better than Fortnite (false)
I couldn't develop the line of reasoning, could you help me? Thanks.
Example: Dota is better than league of legends (true).
Counter Strike is better than Fortnite (false)
I couldn't develop the line of reasoning, could you help me? Thanks.
The simplest way is this:
function findDota (string){
if (string.toLowerCase().search("dota") != -1){
return true;
} else{
return false;
}
}
string.search()
returns the position (0 indexing) of the first occurence of the search parameter in the string. If the search parameter isn't in the string it returns -1.
A more complex answer could use regular expressions
(regexs
) which can be very powerful.
function findDota (string){
if (string.search(/dota/i) != -1){
return true;
} else{
return false;
}
}
here /dota/i
searches for the string dota
. The i
means it is case insensetive.
useful links:
https://www.w3schools.com/jsref/jsref_search.asp