+ 1
How to display all the conversions?
In this only the last value and unit are printed how to print all of them? https://code.sololearn.com/W39f19CgymN1/?ref=app
5 ответов
+ 1
Since there are 2 conversion there, it should be extra num and unit. Eg. num1, unit1, num2, unit2.
Here an change of your app, with some corrections of handling input and res element in react way.
https://code.sololearn.com/WCPX8DycFjqz/?ref=app
+ 1
But your program has just let us select one of the conversion?
0
I mean that after selecting it could print more than one values for example if I enter 5 km it only displays 5000m.
How to make it display both in metres and miles.
I did this but the second setNum and setUnit overrides the previous one and only displays in metres.
if(unit=="km")
{
setNum((num/1.609));
setUnit("miles");
setNum(num*1000);
setUnit("m");
}
0
Thanks for answering.
So if I want to add more conversions I have to add more variables I was wondering if there was an array or something to do this.
0
Hinjaku Hinjaku yes, you can array if more conversions.