Another Algo Question

Another Algo Question
0

#1

This time I did try and run it on console, but couldn’t seem to get it to work.

Here is the algorithm

msg = 'codingdojo';
    for(var x = -1; x < msg.length - 1); x++)
    {
    if (msg.length == 1){
        for (var i = 1; i < 4; i++){
console.log(i);
}
                                  }   
else
{
    for (var i = msg.length; i > (msg.length - 2); i--){
    console.log(i);
}
}
}

If anyone could help would be much appreciated thank you :smile:


#2

The first mistake I see is

You have an extra closing parentheses.


#3

haha thank you so much worked this time :smiley:


#4

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#5

I appreciate this so much! Thanks for the help :slight_smile: