79448855

Date: 2025-02-18 16:04:09
Score: 0.5
Natty:
Report link

I finally found the code :

var a = [145, 234, 23, 56, 134, 123, 78, 124, 234, 23, 56, 98, 34, 111];

var pattern = [234, 23, 56];

//Loop the array in reverse order :
for(var i = a.length - 1; i >= 0; i--)
{   
    if(a.slice(i, i + pattern.length).toString() === pattern.toString())
    {
        console.log("Last index found : "+i);
        
        break;
    }
}
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: totoaussi