Один ответ

A shop sorts its prices with the default sort(). What does this program print when you run it with node?

const prices = [100, 25, 3, 1000];
prices.sort();
console.log(prices);
Один ответ

An import script converts quantity strings to numbers with map(parseInt). What does it print?

const quantities = ["1", "2", "3"].map(parseInt);
console.log(quantities);
Один ответ

What does this program print?

const doubled = [1, 2, 3].forEach((n) => n * 2);
console.log(doubled);
Один ответ

A ticket queue uses splice and slice. What does this program print?

const queue = ["a", "b", "c", "d", "e"];
const taken = queue.splice(1, 2);
const peek = queue.slice(0, 2);
console.log(taken, peek, queue);
Один ответ

A checkout sums the prices in an empty cart. What happens when this program runs?

const cart = [];
const total = cart.reduce((sum, item) => sum + item.price);
console.log(total);
Один ответ

A sensor log contains a failed reading stored as NaN. What does this program print?

const readings = [12, NaN, 7];
console.log(readings.includes(NaN), readings.indexOf(NaN));
Несколько ответов

An order list is searched with find and filter. Which statements are true? Select all that apply.

const orders = [{ id: 1, total: 40 }, { id: 2, total: 90 }, { id: 3, total: 15 }];
console.log(orders.find((o) => o.total > 50));
console.log(orders.filter((o) => o.total > 50));
console.log(orders.find((o) => o.total > 500));
Один ответ

What does this program print?

const names = ["ana", "dan"];
const upper = names.map((n) => { n.toUpperCase(); });
console.log(upper);
Один ответ

True or false: because tags is declared with const, the call tags.push("new") throws an error.

const tags = ["sale"];
tags.push("new");
console.log(tags);
Один ответ

What does this program print?

const scores = [30, 4, 100];
const sorted = scores.sort((a, b) => a - b);
console.log(sorted === scores, scores);