JS_HOME_WORK/43-compare-two-arrays/start.js
2025-02-05 08:47:22 +01:00

25 lines
946 B
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** ЗАДАЧА 43 - Сравнение двух массивов
*
* 1. Создайте функцию "areArraysEqual" с двумя параметрами "firstArray" и "secondArray"
*
* 2. Верните "true" если два массива равны, а именно:
* - имеют одинаковое количество элементов
* - все элементы совпадают, например, firstArray[0] === secondArray[0] и т. д.)
*
* 3. В противном случае верните "false"
*
* ВАЖНО: Исходите из того, что массивы содержат элементы примитивных типов
*/
const a = [1, 2, 3]
const b = [1, 2, 3]
console.log(a === b) // false (Почему?)
const c = [2, 1, 3]
const d = [1, 2, 3, 4]
console.log(areArraysEqual(a, b)) // true
console.log(areArraysEqual(a, c)) // false
console.log(areArraysEqual(a, d)) // false