diff --git a/cards-template1a.js b/cards-template1a.js index 63e0a6c..81d1e49 100644 --- a/cards-template1a.js +++ b/cards-template1a.js @@ -2,19 +2,39 @@ // function()--> possible return values +var card; + + function rank(card) { // --> 1..13 + var rankOfCard = ((card-(card%4))/4)+1; + return rankOfCard; } function suit(card) { // --> 1..4 + var suitOfCard = (card%4)+1; + return suitOfCard; } + function cardID(rank,suit) { // --> 0..51 + var cardIDfound = (4*(rank-1)+(suit-1)); + return cardIDfound; } function color(card) { // -->"red","black" + var column = (card%4); + if (column<=1) { + return 'red'; + } else { + return 'black'; + } } function name(card) { // --> string + var ranks = ['Ace','Two','Three','Four','Five','Six','Seven','Eight','Nine','Ten','Jack','Queen','King']; + var suits = ['Hearts','Diamonds','Spades','Clubs']; + var nameOfCard = ranks[(card-(card%4))/4] + ' of ' + suits[(card%4)]; + return nameOfCard; } diff --git a/cards-template1b.js b/cards-template1b.js index 693102a..5989ac3 100644 --- a/cards-template1b.js +++ b/cards-template1b.js @@ -1,26 +1,75 @@ // Error-detecting version function rank(card) { + var rankOfCard = ((card-(card%4))/4)+1; + if (((card%1)===0)&&(card<=51)){ + return rankOfCard; + } else { + return NaN; + } + } function suit(card) { + var suitOfCard = (card%4)+1; + if (((card%1)===0)&&(card<=51)){ + return suitOfCard; + } else { + return NaN; + } } function cardID(rank,suit) { + var cardIDfound = (4*(rank-1)+(suit-1)); + if (((rank%1)===0)&&(00; i--){ + console.log(i); +} + +//d +if (a&&b){ + x = 0; +}else if (a||b){ + x = 1; +}else { + x = 2; +} + +//3 + +//a +var letter = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']; + +var n; + +function letterTriangle(n){ + var output = ''; + for (var line =0; line=0; col--){ + output = output + letter[col]; + } + output += '\n'; + } + return output; +} + +console.log(letterTriangle(5)); + +//b coming soon! + +// Section 4 + +//a +function and2(a,b){ + if (a = true){ + }else if (b = true) { + return true; + }else { + return false; + } + if (a = false){ + }else if (b = false){ + return true; + }else { + return false; + } + +} + +//hmmm not quite working but not sure why?? +//more coming soon! sorry :( + + + + + + + +