javascript - If Condition on T-shirt -
the t-shirt sizing chart follows:
in order qualified specific sizes, created conditional statements verify range of sizes.
var shirtwidth = 22; // size l (large) var shirtlength = 30 ; // size l (large) var shirtsleeve = 8.79; // size l (large) if((shirtwidth === 18 || shirtwidth === 19) && (shirtlength === 28) && (shirtsleeve >= 8.13 && shirtsleeve <= 8.37)){ console.log('s'); } else if ((shirtwidth === 20 || shirtwidth === 21) && (shirtlength === 29) && (shirtsleeve >= 8.38 && shirtsleeve <= 8.62)){ console.log('m'); } else if ((shirtwidth === 22 || shirtwidth === 23) && (shirtlength === 30) && (shirtsleeve >= 8.63 && shirtsleeve <= 8.87)){ console.log('l'); } else if ((shirtwidth === 24 || shirtwidth === 25) && (shirtlength === 31 || shirtlength === 32) && (shirtsleeve >= 8.88 && shirtsleeve <= 9.62)){ console.log('xl'); } else if ((shirtwidth === 26 || shirtwidth === 27) && (shirtlength === 33) && (shirtsleeve >= 9.63 && shirtsleeve <= 10.12)){ console.log('2xl'); }else if ((shirtwidth === 28) && (shirtlength === 34) && (shirtsleeve >= 10.13)){ console.log('3xl'); }else { console.log('n/a'); }
it seems still wrong. idea doing wrong here? missing logical expressions here?
updates:
- if shirtwidth equals 19, shirtlength equals 28 , shirtsleeve equals 8.21, s should printed console.
- if shirtwidth equals 26, shirtlength equals 33 , shirtsleeve equals 9.63, 2xl should printed console.
- if shirtwidth equals 18, shirtlength equals 29 , shirtsleeve equals 8.47, n/a should printed console.
your code seems right here:
https://repl.it/ksfv/2 @asad saeeduddin's example , data in updates.
but have clue an answer days earlier. in first snippet of answer, used dom dataset deal of them. when retrieving data dataset, appears not in type number
(actually string
). there problem if retrieved data number stored in other types , use strict test (===
). (more guesses, should retrieving data in web pages, should store string
, node
s.)
if put every number determined in if-else-if statement number(/* ... */)
didn't work, should include minimal code reproduce problem. (snippet please)
Comments
Post a Comment