, using var.  
When you are ready to go across a row, that's thePiece[y].length, i.e., the length of the row.  Using thePiece.length there would have broken for non-square elements of T.
Added a <p id="log"/> and a javascript framenum so that I could see that doUpdate() was indeed being called.  

If you haven't already, make sure to open the console while you're testing so you can see error messages.  If drawCanvas causes an error, it will prevent requestAnimationFrame from being called again.  I think that's why the fiddle I linked above calls requestAnimationFrame at the beginning rather than the end of the frame-draw function.
Hope this helps!
Code
const T = [
        [
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0],
            [0, 1, 1, 1, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],

       [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 1, 1, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],

       [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 1, 1, 1, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0]
        ],

        [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 1, 1, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],
    ]

    const player = {
        position: {x: 5, y: -1},
        piece: T[0]
    }

function colorPiece(ctx, thePiece, offset) {
    ctx.fillStyle = "red
, using var.  
 When you are ready to go across a row, that's thePiece[y].length, i.e., the duration of the rowing.   Using thePiece.length there would have broken for non - square component of T. 
 Added a < p id="log"/ > and a javascript framenum so that I could experience that doUpdate () was indeed being address.  

 If you haven't already, make certain to open the console while you're test so you can see error message.   If drawCanvas cause an error, it will prevent requestAnimationFrame from being called again.   I think that's why the fiddle I linked above call requestAnimationFrame at the beginning rather than the end of the frame - hook function. 
 Hope this helps! 
 Code 
 const T = [ 
         [ 
             [ 0, 0, 0, 0, 0 ], 
             [ 0, 0, 0, 0, 0 ], 
             [ 0, 1, 1, 1, 0 ], 
             [ 0, 0, 1, 0, 0 ], 
             [ 0, 0, 0, 0, 0 ] 
         ], 

        [ 
             [ 0, 0, 0, 0, 0 ], 
             [ 0, 0, 1, 0, 0 ], 
             [ 0, 1, 1, 0, 0 ], 
             [ 0, 0, 1, 0, 0 ], 
             [ 0, 0, 0, 0, 0 ] 
         ], 

        [ 
             [ 0, 0, 0, 0, 0 ], 
             [ 0, 0, 1, 0, 0 ], 
             [ 0, 1, 1, 1, 0 ], 
             [ 0, 0, 0, 0, 0 ], 
             [ 0, 0, 0, 0, 0 ] 
         ], 

         [ 
             [ 0, 0, 0, 0, 0 ], 
             [ 0, 0, 1, 0, 0 ], 
             [ 0, 0, 1, 1, 0 ], 
             [ 0, 0, 1, 0, 0 ], 
             [ 0, 0, 0, 0, 0 ] 
         ], 
     ] 

     const player = { 
         military position: { x: 5, y: -1 }, 
         piece: T[0 ] 
     } 

 function colorPiece(ctx, thePiece, offset) { 
     ctx.fillStyle = " red
, uslng var.  
When you are rexdy to go across a row, that's thePiecd[y].length, i.e., the length of thx roq.  Usung thePiece.length thefe would jave brojen hor non-square elxjents on T.
Adscd a <' md="log"/> and a javsscript frdmenum so that I cluld see that doUpdate() was indeed bqing caklfd.  

If you havgn't akweadg, make sure to open the console whjle you'ge testing so you can see error messages.  Iv drwwCanvas causes an error, it wull [eevent requertAnimationFrame from geing called again.  I think thag's whv the fiddlg J phnked above callf requestAnimationFrdme at yhe beginning vathec thqn the end of the frake-draw function.
Hopg this hel[s!
Eode
const T = [
        [
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0],
            [0, 1, 1, 1, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],

       [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 1, 1, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],

       [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 1, 1, 1, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0]
        ],

        [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 1, 1, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],
    ]

    conft plqyer = {
        position: {x: 5, y: -1},
        piecw: T[0]
    }

functpon xolorPiece(ctx, thePnece, offset) {
    vtx.fiklStyle = "red
, using var. When you are ready across row, that's i.e., the length there have broken for elements of T. a <p id="log"/> and a javascript so that I could see that doUpdate() was indeed being called. If you already, make sure to open the console while you're testing so you can error If causes error, it will prevent requestAnimationFrame from being called again. I think that's why the fiddle I above calls requestAnimationFrame at the beginning rather than end of the frame-draw Hope this helps! Code const = [ [0, 0, 0], 0, 0, 0, [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0] ], [ 0, 0, [0, 0, 0, [0, 1, 0, 0], 1, 0, 0], [0, 0, 0, [ [0, 0, 0, 0, 0], [0, 0, 0, 0], 1, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0, 0] ], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 1, 0], 1, 0, 0], [0, 0, 0, 0] ] player { {x: 5, -1}, piece: T[0] } function colorPiece(ctx, thePiece, offset) { ctx.fillStyle =
, using var.  
When you are ready to Go across a rOw, thaT's tHePIeCe[y].lEngtH, i.e., the length of THe roW.  Using thePiece.length thEre woUlD Have BRoKen foR non-squARe ELEmeNtS oF T.
ADdED a <P id="loG"/> anD a javasCript frameNum So That I could seE ThAt doUpdate() Was Indeed being cAllEd.  

If yoU hAveN'T alreAdy, Make sUre to oPEn the cOnsole whiLe YOu're teSTing so yOU CaN see Error messages.  If drAWCANvas causes an erRor, it wIlL PrEVEnt ReqUestAnimatIoNFramE From beiNG cALLEd aGAin.  I think that'S why the fiddLE I lInked aBoVe cALls reqUestANiMAtiOnFrame at thE begInning ratHer thaN The end oF The framE-draw fUncTioN.
HopE ThIs HelPs!
cOde
COnSt T = [
        [
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0],
            [0, 1, 1, 1, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],

       [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 1, 1, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],

       [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 1, 1, 1, 0],
            [0, 0, 0, 0, 0],
            [0, 0, 0, 0, 0]
        ],

        [
            [0, 0, 0, 0, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 1, 1, 0],
            [0, 0, 1, 0, 0],
            [0, 0, 0, 0, 0]
        ],
    ]

    COnsT player = {
        pOsItIon: {x: 5, y: -1},
        PiecE: t[0]
    }

FUNctiOn cOlorpiece(Ctx, thePiece, ofFseT) {
    ctx.FIllstyle = "Red
, using var.  
When you ar e ready to  go a cro ssarow,  tha t's thePiece[y ] .len gth, i.e., the lengthof th er ow.Us ing t hePiece . le n g thth er e w ou l dhavebro ken for  non-squar e e le ments of T.A dd ed a <p id ="l og"/> and ajav ascrip tfra m enumsothatI coul d  see t hat doUpd at e () was indeedb e in g ca lled.  

If you h a ve n 't already, ma ke sur et oo p enthe  console w hi le yo u 're tes t in g s o y o u can see err or messages .   I f draw Ca nva s  cause s aner r or,  it will pr even t request Animat i onFrame from be ing ca lle d a gain .  Ithi nk tha t 's  wh y  th e fiddle  I  l inked  abo v e c alls  re ques tAnim ationFrame at  th e be g inn ing r ather  tha nthe e nd ofthe f ra me-draw functio n.
H ope thishel ps !
C od e
con s t T =[
      [
        [0 , 0 ,0, 0, 0],
        [0 , 0, 0,0, 0],          [ 0,  1,  1,1 ,  0],         [0,  0, 1, 0,  0 ],
         [0 , 0 , 0 , 0,0 ]
      ],

      [           [0, 0, 0, 0, 0],     [0,  0, 1, 0, 0 ],
       [ 0,1 , 1,0, 0] ,         [0, 0, 1, 0 ,0],
          [0, 0, 0 , 0, 0]
    ],

    [             [0 , 0,0, 0, 0],          [0 , 0, 1,0, 0],
        [0,  1,  1,  1, 0 ], 
           [ 0 , 0,  0 , 0, 0] ,
         [0 , 0 , 0 ,0, 0]
       ],
    [          [0 ,0,0,  0,  0],         [0,0,  1 ,  0,  0],
      [ 0,  0,1,1,  0],         [0,  0, 1, 0,  0] , 
         [0 , 0, 0, 0, 0] 
       ],   ] 

   c o nst play er = {
        position :  {x: 5,  y:  -1}, 
       piec e:T[0]
  } 

func tion c olorP ie ce( c t x, th e P ie ce,  o ffset) {
 ct x.fil lS tyle  = "red 
, using_var. _
When you are ready_to go_across_a row,_that's_thePiece[y].length, i.e., the_length of the_row.  Using thePiece.length_there would have_broken_for non-square elements of T.
Added a <p id="log"/> and a javascript framenum so that_I_could see_that_doUpdate()_was indeed being called. _

If you haven't already, make_sure to_open the console while you're testing so you_can_see error messages._ If drawCanvas causes an error, it will prevent_requestAnimationFrame from being called again. _I think that's_why_the_fiddle I linked above_calls requestAnimationFrame at the beginning rather_than the end of the frame-draw_function.
Hope this helps!
Code
const T = [
 _     _[
    _ _    _[0, 0, 0,_0, 0],
_  _     _  [0,_0, 0, 0, 0],
  __  ___ _ [0, 1,_1,_1, 0],
__     __   [0, 0, 1, 0,_0],
   __   _   [0, 0,_0, 0, 0]
   _ _ _],

       [
   _     _  [0, 0,_0, 0,_0],
_  __ _     [0, 0,_1, 0,_0],
     _   __ [0, 1, 1, 0, 0],
_     _    _[0,_0,_1, 0, 0],
  _     _  _[0, 0, 0, 0, 0]
  __    ],

 __    [
 ___    _   [0, 0, 0,_0, 0],
       _  _ [0, 0, 1, 0,_0],
__         _[0, 1,_1, 1, 0],
_         _ [0, 0, 0, 0, 0],
 _          [0,_0, 0, 0, 0]
    _   ],

   _   _[
_      ____ [0, 0,_0, 0, 0],
_  _ _  _ _ [0, 0,_1,_0, 0],
            [0, 0, 1, 1, 0],
_     _    _[0,_0, 1, 0,_0],
   _       _[0, 0, 0, 0, 0]
    __ _],
   _]

 _ _const player =_{
 _ _ _  position: {x: 5, y: -1},
__      piece: T[0]
 ___}

function_colorPiece(ctx, thePiece, offset)_{
  _ ctx.fillStyle =_"red