var landscape = function() {
var result = "";
var flat = function(size) {
for (var count = 0; count < size; count++)
result += "_";
};
var mountain = function(size) {
result += "/";
for (var count = 0; count < size; count++)
result += "'"; //this statement comes first so ,"'" should print first
result += "\\"; //Then this should print "\"
/*
loop will run 4 times. it should print /'\'\'\' to my understanding.
*/
};
flat(3);
mountain(4);
flat(6);
mountain(1);
flat(1);
return result;
};
console.log(landscape());
Why is this returning :_ _ _ / ' ' ' ' \\_ _ _ _ _ _/ ' \\ _
How I think it should return:_ _ _ / ' \ ' \ ' \ ' \ _ _ _ _ _ _ / ' \ _
Please help me understand why its returning like that?
result += "\\";inside of curly brackets with theresult += "'";