I tried so many solutions and I always get an error in the console
This is the question All Upper
My last tried code:
import assert from "assert";
function isAllUpper(text: string): boolean {
// your code here
if(text.length === 0){
return true
}else if(text.trim().length == 0){
return true
}else {
let test = text.toUpperCase()
test == text ? console.log(text, true) : console.log(text, false)
test == text ? true : false
}
}
console.log('Example:');
console.log(isAllUpper(' UPPER'));
console.log(isAllUpper(''));
console.log(isAllUpper('ALL UPPER'));
console.log(isAllUpper('all lower'));
console.log(isAllUpper('mixed UPPER and lower'));
This is the build in console
Example:
UPPER true
undefined
true
ALL UPPER true
undefined
all lower false
undefined
mixed UPPER and lower false
undefined
ALL UPPER true
assert.js:102
throw new AssertionError(obj);
^
AssertionError [ERR_ASSERTION]: undefined == true
at /opt/project/test.ts:31:8
Error in the browser console:
Uncaught TypeError: Cannot read property 'slice' of undefined
Created at: 2020/07/09 08:55; Updated at: 2020/11/17 14:18
The question is resolved.