CoffeeScript: Find the area of a triangle
CoffeeScript: Exercise-4 with Solution
Write a CoffeeScript program to find the area of a triangle where lengths of the three of its sides are 5, 6, 7.
HTML Code :
<!DOCTYPE html> <html> <head> <script src="//jashkenas.github.io/coffee-script/extras/coffee-script.js"></script> <meta charset="utf-8"> <title>Find the area of a triangle</title> </head> <body> </body> </html>
CoffeeScript Code :
side1 = 5 side2 = 6 side3 = 7 perimeter = (side1 + side2 + side3) / 2 area = Math.sqrt(perimeter * (perimeter - side1) * (perimeter - side2) * (perimeter - side3)) console.log area
Live Demo :
See the Pen coffeescript-exercise-4 by w3resource (@w3resource) on CodePen.
Improve this sample solution and post your code through Disqus.
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook