+ 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

24th May 2020, 12:57 PM
Lunu'anaki
Lunu'anaki - avatar
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
25th May 2020, 4:32 AM
Calviղ
Calviղ - avatar
+ 1
But your program has just let us select one of the conversion?
24th May 2020, 1:25 PM
Calviղ
Calviղ - avatar
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"); }
24th May 2020, 1:52 PM
Lunu'anaki
Lunu'anaki - avatar
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.
25th May 2020, 10:07 AM
Lunu'anaki
Lunu'anaki - avatar
0
Hinjaku Hinjaku yes, you can array if more conversions.
25th May 2020, 11:42 AM
Calviղ
Calviղ - avatar