6

I would Encapsulate the names and colors in a data structure Use .map instead of .forEach So something like this; function chartBackgroundColor(collection){ const nameColorMap = { "TripAdvisor": "#00B98B", "Google": "#FFBD00", "Facebook": "#4B6DAA", }; return collection.map(data =...


6

Keep it simple OMDG it took me longer to work out what your code was doing than to write a solution. Some of it seams to have taken the most complex possible path to a solution, and I am still not 100% sure (as I gave up deciphering that code) what the buf_get_with_leading_space means with leading_space. I am assuming you mean leading off bits? I get the ...


4

If I were doing this, I'd start by putting the data into a 2 dimensional array. As raw data, it seems to be pretty much this: default 12 24 36 48 60 36 -0.2 -0.1 0.0 0.15 0.3 48 -0.1 0.0 0.1 0.25 0.4 60 0.0 0.1 0.2 0.35 0.5 I don't do a lot of JavaScript, but I think in JavaScript syntax, that works out to something on this general order: var priceTable ...


3

Since ES6 there is a cleaner solution with Object.fromEntries: const url = 'https://tempuri.org/?token=secret&test=true'; const params = new URL(url).searchParams; Object.fromEntries(params); It will output an object like this: { token: 'secret', test: 'true' } See browser compatibility of Object.fromEntries on MDN. Basically all browsers and Node.js ...


3

Short review; Unless you are writing inline functions, you should stick to using function Using semicolons is preferred, it takes skill and knowledge to avoid the pitfalls of not using semicolons You assign in 1 statement the value of categorizedItems and return it in the next, you might as well return immediately In essence you do a find within a map, not ...


2

UI I noticed that when I add a new task I tried to click on the text "New task" to replace that with the text of the task but then I didn't get a cursor, so then I clicked on the text labeled "Task" and started typing - I could barely tell my text was added but it was black so it was difficult to see it against the black background. ...


2

Helper Functions I see that you've already asked a separate question for the helper functions here, and others have already done a fine job answering it, so I won't add anything to it here. The rewrite I came up with will use a variation of the helper functions that operate directly on the byte array as defined below - this isn't necessary, but I felt these ...


2

There is some very bad naming in the code. Names are too long and have overlapping abstractions. What is a category, there are two types a, b, or c and testnum1 and itemNum2 Due to poor naming the function has lost so much semantic accuracy it takes a second look to see what it is doing. What are you doing? getCategorizedItems getting categorized items?? ...


2

I would start by extracting the relevant data from itemList and create a lookup object that maps the category to the relevant key/itemCategory. const itemCategories = new Map( Object.entries(itemList) .map(([itemCategory, {category}]) => [category, itemCategory]) ); With the above structure you can filter the items and only keep the items that have ...


1

HTML: Your input elements do not have associated labels Use semantic html elements. Why do You use img instead of a regular html button ? CSS: Avoid styling by tags. Use classes instead Avoid using !important. Read about CSS specificity I'd personally create a separate CSS file with the colors I'm pretty sure You do not need all of those prefixes JS: ...


1

You could avoid the unwrap logic by emulating a callable object. This is done by creating a function and attaching members to it. Your predicate class will then boil down to this small chunk of code: const predicate = fn => ( Object.assign((...args) => fn(...args), { and: otherFn => predicate(value => fn(value) && otherFn(value)), ...


1

I believe you could retain the same level of flexibility without managing extra objects by using higher order functions. This also has the advantage of treating the predicates as functions and nothing more. const records = [ { name: 'Andrew' , age: 21, position: 'Developer' }, { name: 'Bill' , age: 26, position: 'Developer' }, { name: 'Chris' , ...


1

I decided to take a crack at simplifying this problem myself as it sounded like a fun challenge. @SᴀᴍOnᴇᴌᴀ already offered a bunch of good advice. The main thing I want to add is how important it is to be able to split up the logic into well-named and easily understandable helper functions. You did have one small helper function in there, but one or two more ...


Only top voted, non community-wiki answers of a minimum length are eligible