Posts

Showing posts from March, 2024

Temperature Converter

 1 Create a react app 2 Create some useStates: tempTop, tempBottom, bottomValue, topValue, paraValue. where, tempTop is the value of top input tempBottom is the value of bottom input. bottomValue is the value of bottom select dropdown. topValue is the value of top select dropdown. paraValue is the value of h1. onChange in inputs, values of tempTop and tempBottom are set. onChange in options of select values of topValue and bottomValue are set. 3 A constant "convert" is created with all the logics where if else and calculations and setStates take place. 4 A useEffect is created that executes constant "convert" when the value of tempTop, tempBottom, topValue, bottomValue. 5 Styling is done.

Random Number Generator

 1 Create react app 2 In App.js, Create a div inside which there are sections and forms. Create useState diceCount, diceType, result where diceCount is no of dices diceType is no of sides in a dice, result is the end result. Create an input whose value is{diceCount} and onChange setdiceCount is set to the target value. Create an select whose value is{diceType} and onChange setdiceType is set to the target value. Options are given with respective value. A constant dice is created with prop side which generates random number. A constant count and type take the value of diceCount and diceType resp. A constant handleSubmit is created with an arrow function of prop e, e.preventDefault() is done to prevent the page to refresh when submitted and prevent default value. if count and type both are present then, constant spin is created which is an empty array. A loop is created which takes, i=0;i<parseInt(count);i++; which means the loop goes on until i is less than the count . where, a c...