How to use Arrow function In Javascript
ES6 Arrow functions enable us to write functions with simpler and shorter syntax. We can utilize this function that will return the Surface area of a Cube. First, we will define a function and pass a (edge) as an argument. we will write the mathematical expression that will return the Surface area of a cube. Finally, we will call the function.
Syntax
surfaceAreaCube = (a) => {
return(6 * a * a)
}
Example: Below is the function to find the Surface area of the Cube:
surfaceAreaCube = (a) => {
return (6 * a * a)
}
let a = 10;
console.log('Surface area = ' + surfaceAreaCube(a));
Output:
Surface area = 600
Surface area of Cube using JavaScript
A cube is a 3-dimensional box-like figure represented in the 3-dimensional plane that has six-shaped faces. It has length, width, and height of the same dimension. Three sides of a cube meet at the same vertex.
We can find the Surface area of Cube in JavaScript by using different ways including, the JavasScript function, Arrow function, and by using class.
Table of Content
- Using JavaScript Function
- Using Arrow function
- Using class
Contact Us