You are given an array of integers nums
. Write a function that returns true
if any value appears more than once in the array. If all elements are unique, return false
.
Requirements:
nums
.true
if there is at least one duplicate value.false
if all values are unique.Example Usage:
// Example 1
const nums1 = [1, 2, 3, 3];
console.log(hasDuplicate(nums1)); // Output: true
// Example 2
const nums2 = [1, 2, 3, 4];
console.log(hasDuplicate(nums2)); // Output: false