Skip to content

Instantly share code, notes, and snippets.

@dp-singh
Created January 18, 2018 03:04
Show Gist options
  • Save dp-singh/e64f594067ef253e23b3c47be8da6d7e to your computer and use it in GitHub Desktop.
Save dp-singh/e64f594067ef253e23b3c47be8da6d7e to your computer and use it in GitHub Desktop.
Type Script loop
//declaration of array
var arr: number[];
//initilization of array
arr = [1, 2, 3, 4, 5, 5, 6, 7, 8]
//for loop
for (var index = 0; index < arr.length; index++) {
console.log(arr[index]);
}
//entry control loop
var index = 0;
while (index < arr.length) {
console.log(arr[index])
index++;
}
//exit control loop
var index = 0;
do {
console.log(arr[index])
index++;
}while(index<arr.length)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment