close

How to concat string and number in Typescript

Hello Guys, How are you all? Hope You all Are Fine. Today we are going to learn How to concat string and number in Typescript in javascript. So Here I am Explain to you all the possible methods here.

Without wasting your time, Let’s start This Article.

How to concat string and number in Typescript ?

  1. How to concat string and number in Typescript ?

    to concat string and number in Typescript
    You could use something like this:
    let pais:string = 'Ecuador'; let codigo:number = 593; let opcionUno:string = this.pais + this.number let opcionDos:string = this.pais.concat(this.number);

  2. How to concat string and number in Typescript ?

    to concat string and number in Typescript
    You could use something like this:
    let pais:string = 'Ecuador'; let codigo:number = 593; let opcionUno:string = this.pais + this.number let opcionDos:string = this.pais.concat(this.number);

Method 1

You could also do something like this:

let month: string | number = currentTime.getMonth();
if (month < 10) month = '0' + month;

Or this:

const month = currentTime.getMonth();
const monthStr = (month < 10 ? "0" : "") + month;

Method 2


You could use something like this:

let pais:string = 'Ecuador';
let codigo:number = 593;
let opcionUno:string = this.pais + this.number
let opcionDos:string = this.pais.concat(this.number);

Summery

It’s all About this article. Hope all method helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you? Thank You.

Leave a Comment