Complete the code to declare a number variable with value 10.
let num: number = [1];The number type variable should be assigned a numeric value without quotes.
Complete the code to check if a number variable is NaN (Not a Number).
if (isNaN([1])) { console.log("Not a number"); }
The isNaN function checks if the value passed is NaN. You should pass the variable name without quotes.
Fix the error in the code to correctly convert a string to a number.
let value: number = Number([1]);The Number function converts a string containing digits to a number. The string must be in quotes.
Fill both blanks to create a number array and get its length.
let numbers: number[] = [[1]]; let length: number = numbers[2];
The array is created with numbers separated by commas. To get the length, use the .length property.
Fill all three blanks to create a map of numbers and filter keys with values greater than 10.
const data: Record<string, number> = {a: 5, b: 15, c: 20};
const filtered = Object.fromEntries(
Object.entries(data).filter(([[1], [2]]) => [3] > 10)
);In the filter, the destructured array elements are the key and value. The value is compared to 10.