Month: January 2021

Love locks on fence.

How to Use a Ternary Operator in an Object Key’s Value in JavaScript 🔑

In this post I only want to show the formatting for a nested ternary operator, because this formatting took me a while to figure out. For my application, I used a function that took two arguments, and each one decided the value of a respective ternary inside of the function. See the example below: The …

How to Use a Ternary Operator in an Object Key’s Value in JavaScript 🔑 Read More »

Bird nest

How to Modify an Object Nested in an Array with React Hooks & Classes! ✨

Using React Hooks Suppose we have the following state of objects nested within an array: In order to edit one of the ingredients without mutating the original state, we need to first make a copy of the original array. We can do this with the spread operator, or .slice(): Or: Now, we may be tempted …

How to Modify an Object Nested in an Array with React Hooks & Classes! ✨ Read More »