-
Notifications
You must be signed in to change notification settings - Fork 1
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
Building blocks #5
Comments
class Block{
constructor(data) {
this.data = data
}
getWidth() {
return this.data[0]
}
getLength() {
return this.data[1]
}
getHeight() {
return this.data[2]
}
getVolume() {
return this.data[0]*this.data[1]*this.data[2]
}
getSurfaceArea() {
return (this.data[0]*this.data[1] + this.data[0]*this.data[2] + this.data[1]*this.data[2])*2
}
} |
提交看了答案这个题目的答案大家都差不多,没有吊打的 |
我的是把每个方法加原型方法上,不懂错在哪了 |
他这个题目是用 es6 的语法 class。话说有空可以熟悉下 es6的语法,我们团队现在都是用 es6了 |
赞!你们团队已经站在互联网前端风口上了!那是不是需要转化es5使用尼--比如 Babel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements
The constructor should take an array as an argument, this will contain 3 integers of the form [width, length, height] from which the Block should be created.
Examples
let b = new Block([2,4,6]) -> creates a
Block
object with a width of2
a length of4
and a height of6
Your Test Cases:
let block = new Block([2,4,6]);
Test.assertEquals(block.getWidth(), 2)
Test.assertEquals(block.getLength(), 4)
Test.assertEquals(block.getHeight(), 6)
Test.assertEquals(block.getVolume(), 48)
Test.assertEquals(block.getSurfaceArea(), 88)
where By
http://www.codewars.com/kata/55b75fcf67e558d3750000a3/train/javascript
The text was updated successfully, but these errors were encountered: