v1
5/3/2023 by corysimmons -00
Setup HTML - click to add setup HTML
Setup JS - click to add setup JavaScript
delete caserun single casemove downdrag and drop case


ready



function parse(data) {
		var result = []
		var current = 0

		data.split('').map((c) => {
			switch (c) {
				case 'i': current++; break
				case 'd': current--; break
				case 's': current = current ** 2; break
				case 'o': result.push(current); break
				default: break
			}
		})

		return result
}

parse("iiisdoso")
parse("iiisxxxdoso")
delete caserun single casemove updrag and drop case


ready



function parse(data) {
  // Keeps only valid characters.
  const validData = data.replace(/[^idso]+/g, "");
  let res = [];
  let value = 0;

  for (const item of validData) {
    if (item === "o") {
        res.push(value);
    }
    value = (item === "i") ? value += 1 : value;
    value = (item === "d") ? value -= 1 : value;
    value = (item === "s") ? value *= value : value;
  }

  return res;
}

parse("iiisdoso")
parse("iiisxxxdoso")
Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN