Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

实现以下代码 #294

Open
lgwebdream opened this issue Jul 6, 2020 · 4 comments
Open

实现以下代码 #294

lgwebdream opened this issue Jul 6, 2020 · 4 comments
Labels
JavaScript teach_tag 快手 company 编程题 teach_tag

Comments

@lgwebdream
Copy link
Owner

function add() {
  // your code
}
function one() {
  // your code
}
function two() {
  // your code
}
console.log(add(one(two()))); //3
console.log(add(two(one()))); //3
@lgwebdream lgwebdream added JavaScript teach_tag 快手 company 编程题 teach_tag labels Jul 6, 2020
@lgwebdream
Copy link
Owner Author

扫描下方二维码,获取答案以及详细解析,同时可解锁800+道前端面试题。

@JS-mark
Copy link

JS-mark commented Aug 17, 2020

有解题思路吗?函数式编程?

@Genzhen
Copy link
Collaborator

Genzhen commented Aug 18, 2020

有解题思路吗?函数式编程?

function add() {
    // your code
    return arguments[0].reduce((a,b)=>a+b)
}
function one() {
    // your code
    if(arguments.length==0){
        return 1
    }else{
        return [arguments[0],1]
    }
    
}
function two() {
    if(arguments.length==0){
        return 2
    }else{
        return [arguments[0],2]
    }
}

console.log(add(one(two())));  //3
console.log(add(two(one())));  //3

@jiangsongyang
Copy link

function add(res) {
  // your code
  return res
}
function one(res) {
  // your code
  const value = 1
  if (res) {
    return res + value
  }
  return value
}
function two(res) {
  // your code
  const value = 2
  if (res) {
    return res + value
  }
  return value
}
console.log(add(one(two()))) //3
console.log(add(two(one()))) //3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JavaScript teach_tag 快手 company 编程题 teach_tag
Projects
None yet
Development

No branches or pull requests

4 participants