小编Swi*_*fty的帖子

尝试创建将我的年龄与其他人的年龄进行比较的函数

尝试创建一个函数来将我的年龄与其他人的年龄进行比较。显然,我错过了一些东西,因为无论输入输出是什么,总是相同的。请帮忙。

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)

javascript algorithm compare function

1
推荐指数
1
解决办法
291
查看次数

标签 统计

algorithm ×1

compare ×1

function ×1

javascript ×1