Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SEI 24 Ray Lee #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<p>temperature converter</p>
<input class="starter" id="input" placeholder="input"/>
<h2>output:</h2>
<p class="starter" id="output"></p>
<p class="starter" id="output">please key in the current temperature</p>
<script>
document.querySelector('#input').addEventListener('change', function(event){
var currentInput = event.target.value;
Expand Down
62 changes: 58 additions & 4 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,61 @@
console.log("hello script js");

var K = 0
var C = 0
var state = 0;
var operation = "";
var temp = 0
var F = 0
var inputHappened = function(currentInput){
console.log( currentInput );
var output = "WOW TEMPERATURE";
return output;
};
if (state===0){
if (Number.isInteger(temp)){
state++;
temp += parseInt(currentInput);
var output = "please key in the temperatureUnit"
} else var output = "please key in an integer"}
if (state === 1){
if (currentInput === "fahrenheit") {
state++;
operation = "fahrenheit";
var K = parseInt(temp)*5/9 - 32*5/9 +273.15;
var C = K - 273.15;
var output = K + " K and " + C + " C";
if(temp <0){
var output =K + " K and " + C + " C" +" ooh its cold out";
} else if (temp>0 && temp<40) {
var output = K + " K and " + C + " C" + " ooh its hot out";}
else if(temp >40){
var output = K + " K and " + C + " C" + " you're literally boiling"};
return output;
} else if (currentInput === "celsius") {
state++;
operation = "celsius";
var F = parseInt(temp)*9/5 + 32;
var K = temp + 273.15;
if(temp <0){
var output =K + " K and " + F + " F" + " ooh its cold out";
} else if (temp>0 && temp<40) {
var output = K + " K and " + F + " F" + " ooh its hot out";}
else if(temp >40){
var output = K + " K and " + F + " F" + " you're literally boiling"}
return output;
} else if (currentInput === "Kelvin") {
state++;
operation = "Kelvin";
var F = parseInt(temp)*9/5 - 273.15*9/5 +32;
var C = temp - 273.15;
var output = F + " F and " + C + " C";
if(temp <0){
var output =C + " C and " + F + " F" + " ooh its cold out";
} else if (temp>0 && temp<40) {
var output = C + " C and " + F + " F" + " ooh its hot out";}
else if(temp >40){
var output = C + " C and " + F + " F" + " you're literally boiling"}
return output;}


// var Kelvin = parseInt(currentInput)*5/9 - 32*5/9 +273.15;
// var C = Kelvin - 273.15
// var output = Kelvin + " K and " + C + " C"

return output;}}