Skip to content

Commit

Permalink
javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi5455 committed May 24, 2024
1 parent 82722f8 commit 0917a07
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,34 @@ function areaCalc(text){
to.value=areaConversionTable[value1][value2];
}

// need to complete->
//Calculating result for menuSelected=weight
function weightCalc(text){
let value1=choice1.value;
let value2=choice2.value;
let num=parseFloat(text);
const weightConversionTable={
kg: {kg: num, g: num*1000, mg: num*1000000, metricton: num*0.001, longton: num*0.0009842073, shortton: 0.0011023122, pound: 2.2046244202, ounce: 35.273990723, carat: 5000, amu: 6.022136652E+26 },
g: {kg: num*0.001, g: num, mg: num*1000, metricton: num*0.000001, longton: num*9.842073304E-7, shortton: 0.0000011023, pound: 0.0022046244, ounce: 0.0352739907, carat: 5, amu: 6.022136652E+23 },
mg: {kg: num*0.000001, g: num*0.001, mg: num, metricton: num*9.999999999E-10, longton: num*9.842073304E-10, shortton: 1.10231221E-9, pound: 0.0000022046, ounce: 0.000035274, carat: 0.005, amu: 602213665200000000000 },
metricton: {kg: num*1000, g: num*1000000, mg: num*1000000000, metricton: num, longton: num*0.9842073304, shortton: 1.1023122101, pound: 2204.6244202, ounce: 35273.990723, carat: 5000000, amu: 6.022136652E+29 },
longton: {kg: num*1016.04608, g: num*1016046.08, mg: num*1016046080, metricton: num*1.01604608, longton: num, shortton: 1.12, pound: 2240, ounce: 35840, carat: 5080230.4, amu: 6.118768338E+29},

shortton: { kg: num*907.184, g: num*907184, mg: num*907184000, metricton: num*0.907184, longton: num*0.8928571429, shortton: num, pound: num*2000, ounce: num*32000, carat: num*4535920, amu: num*5.463186016e+29},
pound: { kg: num*0.453592, g: num*453.592, mg: num*453592, metricton: num*0.000453592, longton: num*0.000446286, shortton: num*0.0005, pound: num, ounce: num*16, carat: num*2267.96, amu: num*2.731593008e+26},
ounce: { kg: num*0.0283495, g: num*28.3495, mg: num*28349.5, metricton: num*0.0000283495, longton: num*0.0000279018, shortton: num*0.00003125, pound: num*0.0625, ounce: num, carat: num*141.7475, amu: num*1.70724563e+25 },
carat: { kg: num*0.0002, g: num*0.2, mg: num*200, metricton: num*2e-7, longton: num*1.96841466e-7, shortton: num*2.20462442e-7, pound: num*0.0004409249, ounce: num*0.0070547981, carat: num, amu: num*1.20442733E+23 },
amu: { kg: num*1.660540199e-27, g: num*1.660540199e-24, mg: num*1.660540199e-21, metricton: num*1.660540199e-30, longton: num*1.634315837e-30, shortton: num*1.830433737e-30, pound: num*3.660867475e-27, ounce: num*5.85738796e-26, carat: num*8.302700999e-24, amu: num }
}
to.value=weightConversionTable[value1][value2];
}

// need to complete->
function timeCalc(text){
let value1=choice1.value;
let value2=choice2.value;
let num=parseFloat(text);
const timeConversionTable={

}
to.value=timeConversionTable[value1][value2];
}

0 comments on commit 0917a07

Please sign in to comment.