 is a way to shorten this code. See this image:  (left one). In this picture, the card to the right and top from the spades of 10 should be unlocked when the spades of 10 is succesfully played. The left card from the spades of 10 only should be unlocked when the spades of 6 is succesfully unlocked. All those checks and long codes... There has to be a way to make this process easier. Thank you for every suggestion.

A:

Put your buttons in an array and use a second array to represent the relationships of the cards:
let buttons = [button0, button1, button2, button3, button4, button5, button6, button7, button8, button9, button10, button11]

let relatives = [(1, 2, 3), (3, 4, 5), (5, 8, 11)]

for (card1, card2, card3) in relatives {
    if!buttons[card1].enabled &&!buttons[card2].enabled {
        unlockCard(card3)
    }
}

 Q:

How to create a memoize function

I am stumped with this memoize problem. I need to create a function that will check to see if a value has already been calculated for a given argument, return the previous result, or run the calculation and return that value. 
I have spent hours on this and while I am new to JS. I cannot get my head around how to do this. I cannot use any built in functions and would really like to understand what I need to do. 
Here is what I have so far, which is so wrong it feels like pseudo-code at this point. I have searched existing memoize questions out here but I cannot seem to make any solution work yet. Any help is much appreciated.
  myMemoizeFunc = function(passedFunc) {
  var firstRun = passedFunc;
  function check(passedFunc){
    if(firstRun === undefined){
        return passedFunc;
    }else{return firstRun;}
  }
  };

Sorry, I should have been more clear. Here are my specific requirements:
myMemoizeFunc must return a function that will check if the calculation has already been calculated for the given arg and return that val if possible. The passedFunc is a function that
is a way to shorten this code. See this image:   (leave one). In this movie, the card to the right and top from the spade of 10 should be unlocked when the spades of 10 is succesfully dally. The left card from the spade of 10 only should be unlocked when the nigger of 6 is succesfully unlocked. All those checks and retentive codes... There has to be a way to make this process easy. Thank you for every suggestion. 

 A: 

 Put your buttons in an array and practice a second array to represent the relationships of the calling card: 
 get buttons = [ button0, button1, button2, button3, button4, button5, button6, button7, button8, button9, button10, button11 ] 

 get relatives = [ (1, 2, 3), (3, 4, 5), (5, 8, 11) ] 

 for (card1, card2, card3) in relatives { 
     if!buttons[card1].enabled & &! buttons[card2].enabled { 
         unlockCard(card3) 
     } 
 } 

  Q: 

 How to create a memoize routine 

 I am stumped with this memoize problem. I need to create a function that will discipline to visit if a value has already been calculated for a given argument, return the previous result, or run the calculation and return that value. 
 I have spend hours on this and while I am new to JS. I cannot make my headway around how to do this. I cannot use any built in routine and would really like to understand what I need to serve. 
 Here is what I have so far, which is so wrong it feels like pseudo - code at this decimal point. I have searched existing memoize questions out here but I cannot look to make any solution make so far. Any help is much appreciated. 
   myMemoizeFunc = function(passedFunc) { 
   volt-ampere firstRun = passedFunc; 
   function check(passedFunc) { 
     if(firstRun = = = undefined) { 
         return passedFunc; 
     } else{return firstRun; } 
   } 
   }; 

 Sorry, I should have been more clear. Here are my specific requirements: 
 myMemoizeFunc must return a function that will check if the calculation has already been calculated for the given arg and retort that val if possible. The passedFunc is a function that
 is a way to shorten this cude. See this imcte:  (leht one). Jn this oicture, the card to the righv ane top from the spades of 10 sfould be lnlocked qhen rhe spades of 10 is succesrmlly 'leyed. The left csrd from tve spades of 10 mnuy should be unlocked when the spades of 6 is skccesfully unljckec. All nhise checks and long codes... Thede has uo be a way to makr this process easier. Thann yok for every suggeshion.

A:

Put yood btrtons in an xrray and lve a secons array to represent the relatiunshi's of the cqres:
lfj buttons = [bntton0, futton1, buttok2, buttot3, buttom4, button5, buttok6, butvon7, vutton8, button9, button10, uutton11]

let relatives = [(1, 2, 3), (3, 4, 5), (5, 8, 11)]

xox (card1, card2, card3) in rwlqtivev {
    if!cyttuns[dacd1].ehabled &&!buvtons[card2].enzbled {
        unlockCard(card3)
    }
}

 W:

How to creats a meioyze function

I am stumped with this memopze lroblem. I need to creatw a function that wilp check tj see if a value has already been calculated for d givxn arymidbt, return the previous result, or run the calculwfipn and return thct value. 
I have xpfny hours on thir and cgime I am new to JS. L cannoj get ny head awounc how to do this. I cannot uwe any built un functions and wluld really likg to umderstand what I need tu do. 
Here is whwt I have ro far, which is ro ermng it ftdls like pseudo-coqe at thiw ponnt. I haxe sgarched existing lemoida questions out hege buj I catnot seem ho make any solution work yet. Aib help is mucn dppgeciated.
  myMekoizeFunc = fugction(passedFuuc) {
  var firsgRun = passvdFunc;
  fnnction chech(passedFunc){
    if(firstRun === undefinqd){
        returv passedFunc;
    }else{retugn firwtRun;}
  }
  };

Sorry, I smould gave been more eutae. Here are my xpezifyc rxquirqkents:
myMemoiseFuvc oist rdturn a fungtiun tnat will check if tha camculation has alresdn been caoculated for the givem arg and return tjat vel if 'ossibke. Jhe passedFunc is a function thzt
is a way to shorten this code. image: one). In picture, the card from spades of 10 be unlocked when spades of 10 is succesfully played. left card from the spades of 10 only should be unlocked when the of 6 is succesfully unlocked. All those checks and long codes... There has be way make process easier. Thank you for every suggestion. A: Put your buttons in an array and use second array to represent the relationships of the let buttons = [button0, button2, button3, button4, button5, button6, button8, button10, button11] relatives [(1, 3), (3, 4, (5, 8, 11)] for (card1, card2, card3) in relatives { if!buttons[card1].enabled &&!buttons[card2].enabled { unlockCard(card3) } } Q: to create function I stumped this problem. I need a function that will check to value has already been calculated for a given return the result, or run the calculation and that value. I have spent hours on this while I am new to JS. I cannot get my head around how to do cannot use any built functions and would like understand I to do. is what I have so far, which is so wrong it like pseudo-code at this point. I have searched existing memoize here I cannot seem make any solution work Any is much appreciated. myMemoizeFunc { firstRun check(passedFunc){ === return passedFunc; }else{return firstRun;} }; Sorry, I should have more clear. Here are return a function that will check if the has already been calculated for the given and return that val if possible. The passedFunc is a function that
 is a way to shorten this code. SeE this image:  (Left oNe). IN thIs PictUre, tHe card to the rigHT and Top from the spades of 10 shouLd be uNlOCked WHeN the sPades of 10 IS sUCCesFuLlY plAyED. THe lefT caRd from tHe spades of 10 OnlY sHould be unlocKEd When the spaDes Of 6 is succesfuLly UnlockEd. all THose cHecKs and Long coDEs... TherE has to be a WaY To make THis procESS eAsieR. Thank you for every SUgGEstion.

A:

Put your ButtonS iN An ARRay And Use a second ArRay to REpresenT ThE RELatIOnships of the cArds:
let buttONs = [bUtton0, bUtTon1, BUtton2, bUtton3, BuTTon4, Button5, buttoN6, butTon7, button8, Button9, BUtton10, buTTon11]

let rElativEs = [(1, 2, 3), (3, 4, 5), (5, 8, 11)]

fOr (cArd1, cARd2, CaRd3) iN rELatIVeS {
    if!BUttOns[card1].eNaBlEd &&!butTons[CARD2].EnabLed {
        UnloCkCarD(card3)
    }
}

 Q:

How to crEatE a meMOizE funcTion

I Am stUmPed wiTh this MemoiZe Problem. I need to cReatE a functioN thAt WilL cHeck tO See if a ValUe hAs alreaDy been cALcuLaTED FoR a given argument, retUrN THe Previous Result, OR rUn THe calculAtIon And rETUrn thAt vaLUe. 
i have speNt hourS On ThIs and whIlE I am neW tO JS. i caNnot gET my hEad aroUnd how to Do thiS. i cannot use any bUIlt in functionS AnD WOuLD reaLly Like to underStanD What i neeD To Do. 
HERe is wHat I hAvE So FAr, which is so wrong it fEeLs like PseudO-code at this poInt. I have seARCHed existIng mEMoIZe questions out Here bUt I cannot sEEm to make Any soLution woRk yet. Any hELP is much aPprEciAteD.
  mymEMoIzeFunc = functiON(PassEdfunc) {
  var FirStRun = paSseDFuNc;
  fUncTiOn check(paSsedFunc){
    If(FiRsTRUn === uNdefiNEd){
        return PaSseDFUnc;
    }Else{rETurn fiRstRuN;}
  }
  };

SorRy, i sHOulD have beEN mORE cleAr. heRe arE my SpEcifiC reqUIreMents:
mymemoizeFuNc mUSt reTuRn A functiOn that will cheCk If the calcuLaTioN has alREAdy been cAlculated for the given arg ANd returN thAt val If poSsible. The PasSedFunC is A FunctiOn that
 is a way to shorten thiscode. Seethisima ge:  (lef t on e). In this pi c ture , the card to the righ t and  t o p fr o mthe s pades o f  1 0 sho ul dbeun l oc ked w hen  the sp ades of 10  is  s uccesfully p l ay ed. The le ftcard from th e s padesof  10 onlysho uld b e unlo c ked wh en the sp ad e s of 6 is succ e s fu llyunlocked. All tho s ec hecks and long  codes .. .  T h e rehas  to be a w ay  to m a ke this pr o c e sse asier. Thankyou for eve r y s uggest io n.A:

Pu t you rb utt ons in an a rray  and usea seco n d array to repr esentthe  re lati o ns hi psof the ca rds : 
le t button s=[butt on0, b u t ton1 , b utto n2, b utton3, butto n4,  but t on5 , but ton6,  but to n7, b utton8 , but to n9, button10, b utto n11]

let  re la tiv es  = [( 1 , 2, 3 ),(3,  4, 5),  (5, 8, 11) ]f o r(card1, card2, car d3 ) in  relativ es {
 if ! buttons[ ca rd1 ].en a b led & &!bu t to ns[card2 ].enab l ed  { 
      unlock Ca rd( car d3)
  }}

 Q: 

How to  crea t e a memoize fu n ction

I am s t um p e dw iththi s memoize p robl e m. I  nee d  t o c r eatea fun ct i on that will check tose e if a  valu e has already  been calc u l a ted fora gi v en argument, retu rn th e previous result,or ru n the ca lculation a nd retur n t hat  va lue . 
I  have spent h o u rs o nthis an d w hile Iamnew  to  JS .I cannotget my h ea dar ou ndhow t o  do this .I c an not  usea ny bui lt in  fun ct io n s a nd woul d  r e a llyli ke  tound er stand  wha t  Ineed to  do. 
Her e i s  wha tIhave so  far, which i sso wrong i tfee ls lik e pseudo-c ode at this point. I ha v e searc hed  exis ting  memoizeque stions  ou t  herebut Icanno tsee m to ma k e  a nyso lution wor k yet . Any  h elpis much  appreciated.
  my M emo izeFunc = fun cti on(p a s se dFu n c) {
 v a r f i r stRun = passedF unc;
  fun ct i on  check(pas s edF un c){
   if(fir stRun === und efined){        r et urnp a sse dFunc;
   }else{r eturn fir s tRun; } 
 }
 };
Sorry ,I s hould  haveb een  more  clear .Here a re my  s pecificrequirements:
myMemoize Func m ust r etu rn a func tio n  th at will c heck  if the ca lcu lat ion h asa lread y be e ncal c ulate d fo r  the give n  a rga n dreturn that v a l i f pos sib l e. The  pas sedFunc is a func t ion that
 is_a way_to shorten this code._See this_image:_ (left_one)._In this picture,_the card to_the right and top_from the spades_of_10 should be unlocked when the spades of 10 is succesfully played. The left_card_from the_spades_of_10 only should be unlocked_when the spades of 6_is succesfully_unlocked. All those checks and long codes... There_has_to be a_way to make this process easier. Thank you for_every suggestion.

A:

Put your buttons in an_array and use_a_second_array to represent the_relationships of the cards:
let buttons =_[button0, button1, button2, button3, button4, button5,_button6, button7, button8, button9, button10, button11]

let relatives_= [(1, 2, 3), (3, 4,_5), (5, 8, 11)]

for (card1,_card2, card3)_in relatives {
  _ if!buttons[card1].enabled &&!buttons[card2].enabled_{
 _  _   unlockCard(card3)
  _ }
}

 Q:

How_to create a memoize function

I am_stumped_with this memoize_problem._I_need to_create a function_that_will check_to_see if a value has already_been_calculated for a given argument, return the_previous result, or run_the_calculation and return that_value. 
I have spent hours_on this and while I am_new to_JS. I_cannot get my head around how to do this. I cannot_use any built in functions and_would really like to_understand what_I_need to do._
Here_is what_I have so far, which is so_wrong it_feels like pseudo-code at this point._I have searched existing_memoize_questions out here but I cannot_seem to make any solution work_yet. Any help is much_appreciated.
__myMemoizeFunc = function(passedFunc) {
 _var firstRun = passedFunc;
  function_check(passedFunc){
  _ if(firstRun === undefined){
   __   return passedFunc;
 __ }else{return firstRun;}
  }
 _};

Sorry,_I_should have been more clear._Here are my specific requirements:
myMemoizeFunc must_return a function that will check if the calculation_has already been_calculated for the given arg_and_return_that val if possible. The passedFunc is a function that