Hi and I'm new to JavaScripts and hopefully anyone of you would help me to figure out. Thanks
My question is how to write a function that expects an array which could contain strings and/or numbers (as well as finite levels of nested arrays of strings and/or numbers), and returns an object which shows the total number of occurences of each unique values.
function functionName() {
const inputArray = [ 2, 5, 2, 'a', [ 'd', 5, 2, ['b', 1], 0 ], 'A', 5, 'b', 2, 'd' ];
const outputResult = functionName(inputArray);
}
The key in the object is the unique values found in the array, and the value for each key is the number of occurences for each unique key
The expected result I want is :
{
'2': 4,
'5': 3,
'a': 1,
'd': 2,
'b': 2,
'1': 1,
'0': 1,
'A': 1,
}