Created
September 18, 2016 20:18
-
-
Save amandasaffer/003b2ba463443a14f0778286a4440e9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".calculate").click(function() { | |
event.preventDefault(); | |
//grab values | |
var chestSize = parseInt($('.chestSize').val()); | |
var waistSize = parseInt($('.waistSize').val()); | |
var height = $(".height").children(":selected").attr("class"); | |
//correct chest and waist values (+1) if odd | |
function oddCheck(x) { | |
if (x % 2 == 0) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
if (oddCheck(chestSize) === false) { | |
chestSize += 1; | |
} | |
if (oddCheck(waistSize) === false) { | |
waistSize += 1; | |
} | |
// calculate | |
var heightInit = height.charAt(0).toUpperCase(); | |
var measurement; | |
if (chestSize - waistSize > 7) { | |
measurement = chestSize; | |
} else { | |
measurement = chestSize + 2; | |
} | |
var size = measurement + " " + heightInit + height.slice(1) + " (" + measurement + heightInit + ")"; | |
//post | |
$('.result').html(''); | |
$('.result').html(size); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment