Skip to content
This repository was archived by the owner on Feb 20, 2019. It is now read-only.

Commit 1aac27a

Browse files
akoliyotKent C. Dodds
authored and
Kent C. Dodds
committed
feat(cube): Add cube function (#119)
Add a function to find the cube of a number.
1 parent 3c21883 commit 1aac27a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/cube.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default cube
2+
3+
/**
4+
* This method will perform cube of a number.
5+
*
6+
* @param {Number} num - Input number
7+
* @return {Number} - Result of cube of a number
8+
*/
9+
10+
function cube(num) {
11+
return num * num * num
12+
}

src/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import subtraction from './subtraction'
2424
import divide from './divide'
2525
import multiply from './multiply'
2626
import square from './square'
27+
import cube from './cube'
2728
import sum from './sum'
2829
import dec2bin from './dec2bin'
2930
import searchAndReplace from './search-and-replace'
@@ -67,6 +68,7 @@ export {
6768
divide,
6869
multiply,
6970
square,
71+
cube,
7072
sum,
7173
dec2bin,
7274
searchAndReplace,

test/cube.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import test from 'ava'
2+
import {cube} from '../src'
3+
4+
test('Cube a number ', t => {
5+
const number = 5
6+
const expected = 5 * 5 * 5
7+
const actual = cube(number)
8+
t.deepEqual(actual, expected)
9+
})

0 commit comments

Comments
 (0)