I am implementing a hash table, where obviously some fields are left undefined, because they have not yet been filled.
I also want to display every field of the hash table. However, when I map through the array the function only returns divs for fields that are not undefined, cant figure out how to force map function to display Empty for undefined fields.
It looks like that for now:
const displayTable = () => {
return storage.map(item => {
if (item == null) {
return <div>undefined</div>
}
return (
<div>
<p>{item[0][0]}</p>
</div>
);
});
With storage being [undefined, undefined, undefined, Array[1], undefined, Array[1], undefined, undefined, undefined, Array[1]]
Thus I end up with only three rendered divs.
undefinedvalues yourself. Instead, it seems thestoragearray is "holey", that is theundefinedvalues represent indexes that were never assigned a value. This would be a useful bit of information to include in the question.