DEV Community

A brief Javascript guide

Chabulsqu on June 18, 2022

Javascript is one of the most used programming languages and in this guide I will review briefly the basics of the language for someone who just wa...
Collapse
 
dovey21 profile image
Somtochukwu Nnaji

This was a pretty nice article although i think there was a mistake in your coding.

    const firstVariable = 'Hello'
    for (let i = 0; i < 6; i++) {
        console.log(firstVariable[i]);
        }
Enter fullscreen mode Exit fullscreen mode

You declared a variable 'i' with the value of 0 but you were now using the keyword to run the loop your code should prolly return an error in ur console log.

Collapse
 
chabulsqu profile image
Chabulsqu

Thank you for replying, I am using the i variable which will first be 0, then 1, etc as the index number of the string so that the code will be
console.log(firstVariable[0])
console.log(firstVariable[1])
But I also found that there was an error in my code, i should have used i < 5 because in the last iteration it prints undefined๐Ÿ˜…

Collapse
 
frankwisniewski profile image
Frank Wisniewski

before published, firstVariable was filled with buenas;-)