I am doing basic JS ex.
I have to check if:

Test.assertEquals(spEng("english"), true);
Test.assertEquals(spEng("egnlish"), false);

has a world ''english". The order of characters is important – a string “abcEnglishdef” is correct but “abcnEglishsef” is not correct.

What I have is:

function spEng(sentence){
if (sentence.includes("english")) {
return true;
} else {
  return false;

This solution doesn’t fit. Can you give me some advices?

well. it fits the tests you created.

other than that it only remains to mention that .includes() tests case-sensitive, so ‘English’ would not match the test string ‘english’.

1 Like

You can also make things more concise like so:

function spEng(sentence){
  return sentence.includes("english");

If you lowercased the sentence before checking it, that will catch any differences of case too.

function spEng(sentence){
  return sentence.toLowerCase().includes("english");

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.