#179 Contains Duplicate

easy
javascript
blind75

Given an array of integers nums, write a function that returns true if any value appears at least twice in the array, and returns false if every element is distinct.

Requirements:

  1. The function should take one argument:
    • An array of integers, nums.
  2. The function should return:
    • 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