const getType = (keyWord) => {
for (const key of Object.keys(keyWords)) {
if (keyWords[key].includes(keyWord)) return key;
}
return null; // if nothing is found
};
P.S. If you decide to get more review comments from my side - you can mention me in comments below.
Argument names should represent what it contains in "real world" (Don't use programming language keywords and shortcuts in function names. For example: array, Object, etc.) https://github.com/chyrkovmaksym/course_project/blob/e30348c34b79af7944c5446e7f94383251f86576/scripts/main.js#L15
You use
if
insideforEach
- it's looks like.filter
or.find
method, so, use them instead: https://github.com/chyrkovmaksym/course_project/blob/e30348c34b79af7944c5446e7f94383251f86576/scripts/main.js#L16-L26If you want to go through each element of array, try find array function which can be fit with your needings: https://github.com/chyrkovmaksym/course_project/blob/e30348c34b79af7944c5446e7f94383251f86576/scripts/parser/cleancode.js#L6-L12
Your record type has different type for values
Record<string, string | string[]>
, it would be better if you switch to justRecord<string, string[]>
: https://github.com/chyrkovmaksym/course_project/blob/e30348c34b79af7944c5446e7f94383251f86576/scripts/drawing/config.js#L17-L23It will help you in future, for example in this case: https://github.com/chyrkovmaksym/course_project/blob/e30348c34b79af7944c5446e7f94383251f86576/scripts/drawing/config.js#L25-L33 You can rewrite with
P.S. If you decide to get more review comments from my side - you can mention me in comments below.