JSFiddle - React, Tailwind, and code Playground

HTML

<script>
	f=a=>(c=d=L=0,e=1,s=[],[...a].map(a=>a=='\n'?c=L=0:c++-(a!=' '&&(s[c]?e=0:(!L&&(d?d-1?e&=c>Q>d-3:d=c>Q>2:d=1),L=s[Q=c]=a)))),e&&'Snickers0KitKat0Starburst0GummyBears0Twix'.split(0).indexOf(s.join``)+1)
</script>
<textarea id = "input" cols = "100" rows = "20"></textarea><br/>
<input id = "result" type = "text"><br/>
<input id = "compute" type = "button" value = "Compute">

JavaScript

const ge = a => document.getElementById(a);
const input = ge('input');
const result = ge('result');
const compute = ge('compute');

compute.addEventListener('click', a => a.button === 0 && (result.value = !!f(input.value)));