Can’t seem to get a hang of this “Twilio Quest” Challenge.
Hey, I’ve been playing this game called “Twilio Quest” for the past week.
I just wanted to learn JavaScript, and I think it looked kinda neat.
The challenges served has been up and down in difficulty. But I’ve always managed to get around, until now.
Been reading through: JavaScript.info – Classes, MDN – Classes, JavaScript.info – Object literal notation and MDN – Object Initialization I tried alot of aproaches. But I really can’t seem to get a hang of this challenge.
Any help would be really appreciated. I just want to learn. Thanks in advance.
Heres what I’m trying to do:
JavaScript
x
18
18
1
class TargetingSolution {
2
constructor(config) {
3
// your code here
4
}
5
6
// your code here
7
}
8
9
// The following lines of code are not required for the solution, but can be
10
// used by you to test your solution.
11
const m = new TargetingSolution({
12
x: 10,
13
y: 15,
14
z: 900
15
});
16
17
console.log(m.target()); // would print "(10, 15, 900)"
18
Advertisement
Answer
JavaScript
1
15
15
1
class TargetingSolution {
2
constructor(config) {
3
this.value = `(${config.x}, ${config.y}, ${config.z})`
4
this.target = () => this.value;
5
}
6
}
7
8
let m = new TargetingSolution({
9
x: 10,
10
y: 15,
11
z: 900
12
});
13
14
console.log(m.target());
15