尝试创建一个函数来将我的年龄与其他人的年龄进行比较。显然,我错过了一些东西,因为无论输入输出是什么,总是相同的。请帮忙。
This is what I have so far:
function compareAge(name,age){
let myAge=27;
if (age = myAge){
return `${name} is the same age as me.`
}else if (age < myAge){
return `${name} is younger than me.`
}else if (age > myAge){
return `${name} is older than me.`
}
}
console.log(compareAge('Kat',2));
Run Code Online (Sandbox Code Playgroud)