Complete the code to declare a typed array of numbers.
let numbers: [1] = [1, 2, 3, 4];
Typed arrays specify the type of elements they hold. Here, number[] means an array of numbers.
Complete the code to declare a typed array of strings.
const fruits: [1] = ['apple', 'banana', 'cherry'];
The array holds strings, so the type string[] is correct.
Fix the error in the typed array declaration.
let flags: [1] = [true, false, true];The array contains boolean values, so the type must be boolean[].
Fill both blanks to declare a typed array and add a new element.
let scores: [1] = [10, 20, 30]; scores.[2](40);
The array holds numbers, so number[] is correct. To add an element, use the push method.
Fill all three blanks to declare a typed array, add an element, and access an element.
let names: [1] = ['Alice', 'Bob']; names.[2]('Carol'); const first: [3] = names[0];
The array holds strings, so string[] is correct. Use push to add an element. Accessing an element returns a string.
