Skip to content

build array of json object while looping array of data

I have an array const A=[‘string1′,’string2′,’string3’]. I want to achieve an object that has the following form: This is what I’ve tried: But the result is an array filled with undefined values. Answer I do not understand why are you using JSON.stringify()? The simpl…

4th argument in reduce

Here is the function: The fourth argument to reduce is the array that we’re iterating over. I can log it and I get the correct result (10) see above. But when I try to use it and assign it to a variable I get an error(see above). Could someone please shed some light? Answer From Mozilla’s page, th…

React hook form how to check if mails are equal

I wonder how to check if 2 inputs are equal? I mean I want to do form validation in which I will check if first input is the same as second one. Anyone knows how to do it? If something is unclear feel free to ask 🙂 Answer Its quite simple. you get the values on onSubmit = (data) so