How to return boolean from function in TypeScript

1 Answer

0 votes
function equal(s1 : string, s2 : string) : boolean {
    return s1 === s2
}

const str1 = "abc";
const str2 = "abc";
 

console.log(equal(str1, str2) ? "yes" : "nos");
 
 

 
/*
run:
 
 "yes
 
*/

 



answered Jan 19, 2022 by avibootz

Related questions

4 answers 133 views
1 answer 141 views
1 answer 144 views
2 answers 196 views
5 answers 370 views
1 answer 124 views
...