My code is not so long so I am pasting all of it here.
The code is not complete but when I run it it first jumps to case "start" which it is supposed to, and then jumps to case "end". I can see it because it prints both blocks' console log texts. Why is it jumping to the "end" case?
<html>
<body>
<script>
function stepStream(stream,step){
switch (stream[step]){
case "start":
console.log("Started reading stream...");
case "end":
var success = "Finished reading dataStream.";
console.log(success);
return success;
default:
throw "Data stream format is bad";
case "gesture":
console.log("Running case gesture! But why?");
step+=1;
stepStream(stream,step);
case "say":
step+=1;
stepStream(stream,step);
case "sleep":
step+=1;
stepStream(stream,step);
}
}
var sentence1 = "Where are my bananas? I thought you put them in my bag?";
var sentence2 = "This is a rather irritating situattion.";
var dataStream = ["start","gesture","banzai","sleep",1.0,"say",sentence1,
"say",sentence2,"gesture","kubikasige","end"];
stepStream(dataStream,0);//Second parameter sets where to start reading the dataStream.
</script>
</body>
</html>