Design comparison
Solution retrospective
Hi everyone π
What do you think of my solution? π
I was originally setting the img src using .outerHTML
but I did some research and found that this may be vulnerable to XSS (cross site scripting) attacks. β π π β
So I used this solution instead where we create an instance of the Image class and set the src attribute on it programatically. This will prevent script injection if the data.json
file is corrupt. πͺ
I enjoyed refactoring this code as I started off with verbose and repetitive code then gradually made it better, especially by using the array.prototype.reduce()
and forEach() functions.
How else can I improve my component fam?
AngusG
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord