@jlcfly
Full-stack developer specializing in healthcare IT
I am a full-stack developer with over 20 years experience. I specialize in healthcare IT. I consider myself a pragmatic developer, using the tools that I know to do the job, and only learning new tools when the situation calls for it. I like to keep up with trending technologies, just so I am aware of what's out there, even though I may not learn/use them myself.
Nothing here yet.
No blogs yet.
Hope you figured it out by now, but if not... for (let i= 0 ; i<item.ratings.length; i++){ if (userId !== item.ratings[i].userId){ alert = false item.ratings.push(ratingObject) return } } It's adding the rating if the userId doesn't match, but if it does, it will simply return. The issue is that there's already a userId in the ratings array, before you get to "kris" (userId "fg12cy"). So, it will add it every time because it sees it exists every time. You need to change this loop to look for the user, and track if it's found or not, and only if it's not found after getting out of the loop should you add it to the ratings array. By the way, "alert" is a javascript function, so I would avoid using that as a variable name, unless you intend to override the javascript function. Also, the "return" in the for loop will return from the fat arrow function. Not sure if that's what you intended, or if you just wanted to exit the for loop early but stay in the fat arrow function. To exit a for loop early, use "break". Here's code with a couple of adjustments: function rateProduct ( description, userId, rate ) { let correctDescription = true let ratingObject = {} ratingObject.userId = userId ratingObject.rate = rate let found = false products.forEach( ( item ) => { if (description === item.description){ correctDescription = true ; for ( let i= 0 ; i<item.ratings.length; i++){ if (userId === item.ratings[i].userId){ found = true break } } if (!found) { item.ratings.push(ratingObject) } } else { correctDescription = false } }) if (!correctDescription){ return "No product is found to be rated" } else if (found) { return "You've already rated this product" } return products } Hope this helps.
I've only played around with it a little, but really like it. I'll probably use it in future projects. One disadvantage to utility first is one school of thought thought that CSS class names shouldn't describe the style. For example, don't name a class "blue-button". What if you want the button to be green later? I've heard of this from the early days onward, and it's still perpetuated today. I have never felt comfortable with that idea and have broken it thousands of times for myself, so this isn't much of a disadvantage to me. It might be for some who who strictly follow such rules.
If you put five paragraphs in, you get five columns. Ideally, you'd want to have paragraphs flow down the left-most column, then over to the right-most, and not necessarily breaking at the paragraph tag. It would also need to scale somewhat with window size. I found that the css column-count does not work with display: flex. If getting rid of display: flex and adding column-count: 2 it works and you don't need the break-inside: avoid. I haven't used column functionality at all before, but look at this: https://www.w3schools.com/css/css3_multiple_columns.asp
I have little interest in mobile development, though I can see myself having to delve into it in full force in the future. Thus far, I've been able to steer clear of it. That said, if I had to, I would go with the one where there were the most employment opportunities. Right now, it seems that's React Native. Also, the carry over between React and React Native opens the employment scope up a bit more. But if you're in it for the enjoyment, try both and see what you like.
Not sure about your poll options. And I'm a little confused about your description. Why is "AAbcdd123444" unacceptable? The repeating characters aren't consecutive. That said, the one I came up with that matched on all three of your unacceptable answers, and did not match on your acceptable answers is this: /([A-Za-z0-9])\1{1,}.*([A-Za-z0-9])\2{1,}.*([A-Za-z0-9])\3{1,}/g I would do an inverse match, meaning, if the match is positive, the result is unacceptable. So, something like: let pattern = /([A-Za-z0-9])\1{1,}.*([A-Za-z0-9])\2{1,}.*([A-Za-z0-9])\3{1,}/g ; let strings = [ 'A123bcd456' , 'Abcd12345678' , 'AAbcdd123456' , // all ok 'AAbbcc123456' , 'AAAbbccc1234' , 'AAbcdd123444' // all not ok ]; strings.forEach( function ( string ) { if (! string .match(pattern)) { console .log( string + ' is ok' ); } else { console .log( string + ' is not ok' ); } }); Result: A123bcd456 is ok Abcd12345678 is ok AAbcdd123456 is ok AAbbcc123456 is not ok AAAbbccc1234 is not ok AAbcdd123444 is not ok
Looks good. That said, because you said it's for learning purposes, I'm willing to give you a pass. If this were for real, I'd say it's way overkill. (I'm betting you already know that, though. LOL!) The app.js alone is almost 3mb, which takes about 6 seconds over a fast 3G network (almost 20 seconds over slow 3G.) It looks like you were able to cut out a huge amount of TailwindCSS. Did you use PurgeCSS for that? I recently discovered TailwindCSS and am really liking it, though I'm not a huge fan of all those classes being in the HTML directly. If I might make a suggestion: I would look for patterns and configure classes to apply tailwind classes to it. Your checkmarks would be a good candidate for that since they're used over and over. You know, the DRY principle. For example, instead of this for every single checkbox: class = "material-design-icon checkbox-marked-circle-icon pr-2 text-green-500" It might be just this: class = "my-checkmark" Then in my styles.css, before building the end result, after the tailwind imports, I'd have something like this: @import "tailwindcss/base" ; @import "tailwindcss/components" ; @import "tailwindcss/utilities" ; . my -checkmark { @apply material-design-icon; @apply checkbox-marked-circle-icon; @apply pr- 2 ; @apply text-green- 500 ; } That's just me, though, since I like to see less cluttered HTML, if at all possible. It's still utility-first, but more in the css file instead of the HTML. This is one reason I like Tailwind. It allows for this level of customization so best practices can be retained and keep HTML relative uncluttered. (Of course, I would never name it "my-checkmark". That's just for demonstration purposes.)
Gave it a try a few months ago. Slow as molasses, even on 200+Mbps connection. I know it's because of the encryption and the hopping, but it was quite unusable, in my opinion. Just downloaded it again. fast.com without Tor for me = 220-230 Mbps fast.com with Tor for me = 3.0-4.0 Mbps Would love to use it more regularly, but the slowness speed makes it way too prohibitive.