TypeScript is a strongly typed programming language that builds on JavaScript. It is developed and maintained by Microsoft and compiles to plain JavaScript.

How to test

Prerequisites: Node.js and TypeScript compiler

  • Install Node.js: https://nodejs.org/
  • Install TypeScript: npm install -g typescript
tsc fibonacci.ts && node fibonacci.js

Expected output:

0
1
1
2
3
5
8
13
21
34

Source Code

let a: number = 0;
let b: number = 1;

for (let i = 0; i < 10; i++) {
  console.log(a);
  [a, b] = [b, a + b];
}

Local Testing Screenshot Image