- You dont need {} everytime for an expression, you only use it to segment blocks of code you want separate from other processes.
- You didn't need this line:
let letterCount = StringB.replace(/\s+/g, '').length;
Just StringB.length is going to give the number of letters in StringB
- Finally you did not check if their lengths are equal your conditions were just if one is greater than the other. In real life you want your code to be dynamic and work regardless of the users input... if my superhero and sidekick have the same length of names, your code will print out StringF (the Sidekick's got the longest name, it has), also it doesnt say how long the sidekick's name is.
let superhero = 'batMan'
console.log(`My favorite superhero's name is ${superhero}`)
let sidekick = 'Robin'
console.log(`The sidekick's name is ${sidekick}`)
if(superhero.length > sidekick.length) {
console.log(`The Hero's got the longest name, it has ${superhero.length} characters`)
}
else if(sidekick.length > superhero.length){
console.log(`the Sidekick's got the longest name, it has ${sidekick.length} characters`)
}
else{
console.log(`wow, they both got equally long names, ${sidekick.length} characters!!`)
}