Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
const result = {}
const dateArr = ['2021-08-06', '2021-11-06', '2021-08-06', '2021-13-06']
// Loop through each item in the dateArr array
for (let i = 0; i < dateArr.length; i++) {
  // Get the value for the current iteration of the loop
  const date = dateArr[i]
  
  // If the results array hasn't seen this value before then define it.
  // It starts as zero so that the last line can always increment.
  if (!result[date]) {
    result[date] = 0
  }
  
  // Increment the number of times we've seen this date by 1.
  result[date]++
}
console.log(result)
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers