I am writing a little program with javascript and html canvas. It is my first javascript program. It will make the dragonCurve thing. But I am getting this error:TypeError: old is undefined. I am not the first one with this question but after reading the other questions I still couldn't find a solution.
The following code is part of the program where it raises an error. So why does it give an error?
<script>
var r = 'r';
var l = 'l';
var old = r;
var newer = old;
var iteration = 10;
var cycle = 1;
while (cycle < iteration){
newer = (old) + (r);
old = old.reversed;
var oldstring = old.split(""); <!-- here is the error -->
cycle++;
}
</script>
var iteration = 20;at the top of the code