Discussion

#179 Contains Duplicate

easy
javascript
blind75

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:

  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