( ! ) Notice: Undefined index: description in /home/prototurk.com/public_html/app/controller/demo.php on line 171 Call Stack # Time Memory Function Location 1 0.0001 362216 {main}( ) .../index.php:0 2 0.0027 444064 require( '/home/prototurk.com/public_html/app/controller/demo.php' ) .../index.php:101
let names = ['Tayfun', 'Mehmet', 'Ahmet', 'Gökhan', 'Tayfun']
let countedNames = names.reduce(function (allNames, name) {
if (name in allNames) {
allNames[name]++
} else {
allNames[name] = 1
}
return allNames
}, {})
console.log(countedNames)
// { Tayfun: 2, Mehmet: 1, Ahmet: 1, 'Gökhan': 1 }