Hi Friends đź‘‹,

Welcome To Infinitbility! ❤️

To each character of string in typescript, use for...of loop, it will return each character one by one. You have to just use for...of loop on your string string.

Let’s see short example to use for loop on string to get each char.

for (let char of string) {
  console.log(char)
}

Today, I’m going to show you How do I get each character of string in typescript, as above mentioned, I’m going to use the for...of loop method to get every char.

Let’s start today’s tutorial how do you get each character of string in typescript?

Typescript get each character of string example

Here, we will take string variable with some data and use for...of loop method to get each char of string.

let string: string = "Infinitbility";

for (let char of string) {
  console.log(char)
}

// Output
// 'I'
// 'n'
// 'f'
// 'i'
// 'n'
// 'i'
// 't'
// 'b'
// 'i'
// 'l'
// 'i'
// 't'
// 'y'

Output

typescript get each character of string example
typescript get each character of string example

I hope it helps you, All the best đź‘Ť.