Learn Functional Programming by Building a Spreadsheet

I don’t understand the requirement of this line:

const charRange = (start, end) => range(start.charCodeAt(0), end.charCodeAt(0)).map(code => String.fromCharCode(code));

When it works literally the same without it here:

const range = (start, end) => Array(end - start + 1).fill(start).map((element, index) => element + index);

It just made me feel confused and kinda made me waste some time understanding the functionality of that piece of code, when it is expendable IMO

I’ve been discusing it with ChatGPT and isn’t expendable after all. We have had a long discussion and we emd to the conclusion that, in fact, it is necessary because some JavaScript’s automatic behaviour with this type of lines: end - start + 1

It seems that JavaScript, even though end and start are alphabetic characters, it converts them to Unicode due to the arithmetical operation.

I would just leave this here in case someone have the same doubt as me, I think is interesting

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.