To find the area of a rectangle in TypeScript, we need to multiply the length and the width of the rectangle.
Here is the code to find the area of a rectangle in TypeScript:
index.ts295 chars11 linesIn the above code, we have defined a function called findRectangleArea that takes two arguments: length and width, both of type number. We then multiply the two values and store the result in a variable called area. Finally, we return the area.
In the main program, we have defined the length and width of the rectangle, and then we call the findRectangleArea function with these values. We store the returned value in a variable called area and then output the result using console.log.
The output of the above program will be:
index.ts51 chars2 lines
gistlibby LogSnag