diff --git a/Calculators/Unit-Calculator/index.html b/Calculators/Unit-Calculator/index.html index 7fc1fdeef..6f59486f9 100644 --- a/Calculators/Unit-Calculator/index.html +++ b/Calculators/Unit-Calculator/index.html @@ -15,6 +15,7 @@

Unit Calculator

+
@@ -30,7 +31,9 @@

Unit Calculator

- + + +

Result: 0

diff --git a/Calculators/Unit-Calculator/script.js b/Calculators/Unit-Calculator/script.js index e8ee9c0f6..7b8ca1d32 100644 --- a/Calculators/Unit-Calculator/script.js +++ b/Calculators/Unit-Calculator/script.js @@ -13,6 +13,7 @@ function updateUnitsDropdown(type) { "square foot", ], weight: ["kilogram", "gram", "ounce", "pound", "ton"], + work: ["Joule", "electron Volt", "calorie", "kcal", "kWh"], //work units volume: [ "cubic meter", "cubic kilometer", @@ -164,6 +165,39 @@ function convert() { pound: (value) => value * 2205, }, }, + work: { + //conversion units for work + Joule: { + "electron-Volt": (value) => value / 1.60218e-19, + calorie: (value) => value / 4.184, + kcal: (value) => value / 4184, + kWh: (value) => value / 3.6e6 + }, + "electron Volt": { + Joule: (value) => value * 1.60218e-19, + calorie: (value) => value * 1.60218e-19 / 4.184, + kcal: (value) => value * 1.60218e-19 / 4184, + kWh: (value) => value * 1.60218e-19 / 3.6e6 + }, + calorie: { + Joule: (value) => value * 4.184, + "electron Volt": (value) => value * 4.184 / 1.60218e-19, + kcal: (value) => value / 1000, + kWh: (value) => value * 4.184 / 3.6e6 + }, + kcal: { + Joule: (value) => value * 4184, + "electron Volt": (value) => value * 4184 / 1.60218e-19, + calorie: (value) => value * 1000, + kWh: (value) => value * 4184 / 3.6e6 + }, + kWh: { + Joule: (value) => value * 3.6e6, + "electron-Volt": (value) => value * 3.6e6 / 1.60218e-19, + calorie: (value) => value * 3.6e6 / 4.184, + kcal: (value) => value * 3.6e6 / 4184 + } + }, volume: { // Conversion factors for volume units "cubic meter": { diff --git a/Calculators/Work-Calculator/index.html b/Calculators/Work-Calculator/index.html index 921769ecb..015cf6f19 100644 --- a/Calculators/Work-Calculator/index.html +++ b/Calculators/Work-Calculator/index.html @@ -25,4 +25,4 @@

Work Calculator

- + \ No newline at end of file diff --git a/Calculators/Work-Calculator/script.js b/Calculators/Work-Calculator/script.js index ea1847ac5..16625ca1c 100644 --- a/Calculators/Work-Calculator/script.js +++ b/Calculators/Work-Calculator/script.js @@ -27,4 +27,3 @@ document.getElementById('workForm').addEventListener('submit', function(e) { document.getElementById('result').style.color = 'green'; } }); - diff --git a/Calculators/Work-Calculator/style.css b/Calculators/Work-Calculator/style.css index 3269a76d5..842a4c6f7 100644 --- a/Calculators/Work-Calculator/style.css +++ b/Calculators/Work-Calculator/style.css @@ -65,7 +65,7 @@ button:hover { align-items: center; border:solid; border-radius: 10px; - height:4vh; + height:4vh; margin-top: 20px; font-size: 1.2em; color: red;