I'm just curious about doing asynchronous job with javascript or typescript.
I made some program with C# and following is source that I wrote.
static void Main(string[] args)
{
var t1= Task.Run(() => { myFunc(0, ConsoleColor.Green); });
var t2 = Task.Run(() => { myFunc(50000, ConsoleColor.Red); });
t1.Wait();
t2.Wait();
}
static void myFunc(int number, ConsoleColor color)
{
for (int i = 0; i < 1e4; i++)
{
Console.ForegroundColor = color;
Console.WriteLine(number + i);
}
}
below is capture image of result.

I can imagine that why console does write above result.
and following source is written in typescript. I tried to simulate same result, but failed.
let i: number;
let j: string;
let k: number;
let mx: number =1e4;
function myFunc(offset: number, color: string) {
return new Promise(() => {
for (i = 0; i < mx; i++) {
console.log(color, i + offset);
}
});
};
async function myFunc2() {
const aa = myFunc(0, "\x1b[32m");
const bb = myFunc(50000, "\x1b[35m");
await aa;
await bb;
}
myFunc2();
below image is typescript one.

can I get any advice for making same result with C# result in `java(type)script? I tried many times to implement, but many time I failed.
thank you for read.