Question 1
Javascript function indexOf
returns -1 if there is no match in the string, not a falsy value. The following code can resolve the issue.
function validateString(str) {
if (str.toLowerCase().indexOf('superman') === -1) {
throw new Error('String does not contain superman');
}
}