I'm new in TS, but i didn't find answer for my question, so that's why I'm here)
I'm trying to create an array of arrays, that may contain only strongly typed data. For example like [[string, number], [string, number], [string, number], ...]
I tried to write such simple code:
let arr: Array<[string, number]> = [['dad\'s adidas', 123], ['moms gucci', 47]]
for (let i = 0; i < arr.length; i++) {
for (let j = 0; i < arr[i].length; j++) {
console.log(arr[i][j])
}
console.log('\n')
}
but the The compiler swears and give me this stupid error))
Uncaught SyntaxError C:\Users\sv25b\UbuntuProjects\WTF\main.ts:1
let arr: Array<[string, number]> = [['dad\'s adidas', 123], ['moms gucci', 47]]
What did I do wrong?
npm install tsx
- install typescript runner
npm install --global tsx
npx tsx watch main.ts
to run your file, in watch mode (restarting on file save)
tsx watch main.ts
if you've installed tsx globallyundefined
i < arr[i].length
to j < arr[i].length