Another Algo Question

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:

The first mistake I see is

You have an extra closing parentheses.

1 Like

haha thank you so much worked this time :smiley:

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.

markdown_Forums

1 Like

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