JSFiddle - React, Tailwind, and code Playground

by saidulu401

HTML

<div class="ps-content-wrapper-v0">
<p>In this challenge, use <em>Javascript Promises</em> to calculate the areas of various geometrical shapes. The shapes are square, rectangle, circle and triangle, and the area of each can be computed using these formulae:</p>

<ul>
	<li>Square of side '<em>a</em>': Area = <em>a<sup>2</sup></em>&nbsp;</li>
	<li>Rectangle of length '<em>l</em>' and width '<em>w</em>': Area = <em>w x l</em>
</li>
	<li>Circle of radius '<em>r</em>': Area =<em> Pi x r<sup>2</sup></em>&nbsp;</li>
	<li>Triangle of base '<em>b</em>' and height '<em>h</em>': Area = <em>0.5 x b x h&nbsp;</em>
</li>
</ul>

<p><em>Note</em>: Make sure to use the value of <em>Pi</em> as <em>3.14</em> and round off the areas of all shapes to 2 decimal places.</p>

<p>&nbsp;</p>

<p><strong>Function Descriptions</strong></p>

<p>&nbsp;</p>

<p>Complete the function <code>getAreas</code> &nbsp;that takes an array of shapes and their respective sides and returns a promise that represents an array of areas of all of the shapes. Also, complete the helper function <code>calculateArea</code> that takes a single shape and its side/sides and also returns a promise that represents its area.</p>

<p>&nbsp;</p>

<p>The specifications of the promise returned by <code>getAreas</code> are as follows:</p>

<ul>
	<li>This Promise consolidates outputs of all promises returned by <code>calculateArea</code> for shapes.</li>
</ul>

<p>&nbsp;</p>

<p>The specifications of the promise returned by <code>calculateArea</code> are as follows:</p>

<ul>
	<li>If the shape&nbsp;passed to the Promise is valid, resolve it with the calculated area of the respective shape.</li>
	<li>If the shape passed to the Promise is invalid, reject everything with <em>[-1]</em>.</li>
</ul>

<p>&nbsp;</p>

<p><strong>Constraints</strong></p>

<ul>
	<li>&nbsp;<em>1</em> ≤ number of shapes&nbsp;&nbsp;≤ <em>2000</em>
</li>
	<li>&nbsp;<em>1</em>&nbsp;&nbsp;≤ length of sides for all shapes&nbsp;&nbsp;≤...