javascript “Twilio Quest”挑战赛,任何帮助都将不胜感激,我不知道我做错了什么,

46qrfjad  于 2023-03-16  发布在  Java
关注(0)|答案(3)|浏览(126)

似乎无法掌握这个“Twilio Quest”挑战的窍门。

嘿,我一直在玩这个游戏叫“Twilio追求”在过去的一周。
我只是想学习JavaScript,我觉得它看起来很整洁。
我所面对的挑战是困难重重的,但我总是设法应付过去,直到现在。
阅读:JavaScript.info - ClassesMDN - Classes,JavaScript.info-对象文字表示法和MDN - Object Initialization我尝试了很多方法,但我似乎真的无法抓住这个挑战的窍门。
这就是我要做的:

class TargetingSolution {
  constructor(config) {
    // your code here
  }

  // your code here
}

// The following lines of code are not required for the solution, but can be
// used by you to test your solution.
const m = new TargetingSolution({
  x: 10,
  y: 15,
  z: 900
});

console.log(m.target()); // would print "(10, 15, 900)"
l0oc07j2

l0oc07j21#

class TargetingSolution{
    x = 0;
    y = 0;
    z = 0;
    constructor(config){
        this.x = config.x;
        this.y = config.y;
        this.z = config.z;
    }
    target(){
        return '('+this.x+', '+this.y+', '+this.z+')';
    }
}
v8wbuo2f

v8wbuo2f2#

class TargetingSolution {
constructor (object) {
this.xcoord= String(object.x)
this.ycoord = String(object.y)
this.zcoord = String(object.z)
}
target() {
return ('('+this.xcoord+', '+this.ycoord+', '+this.zcoord+')')
}}
const sln = new TargetingSolution ({
X: 45,
y: 12,
z: -1
})
console.log(sln.target())
9wbgstp7

9wbgstp73#

class TargetingSolution {
  constructor(config) {
    this.value = `(${config.x}, ${config.y}, ${config.z})`
    this.target = () => this.value;
  }
}

let m = new TargetingSolution({
  x: 10,
  y: 15,
  z: 900
});

console.log(m.target());

相关问题