JavaScript Practice Exercises For Beginners: Beginner Exercises Part 1

In this tutorial, you’ll get a chance to have a go at some JavaScript practice exercises for beginners and then review a possible solution. Grab a free copy of the PDF here 👉 and you can work through all the exercises at your own pace.

Follow me on Twitter:

Want to work through the JavaScript exercises for beginners offline? Grab a copy of the PDF here: and you can work through all the exercises at your own pace.

It’s important to practice your JavaScript coding skills but it can be tricky to find decent problems to solve and then you’re always left wondering – is there a different or better way of solving the problem?

In these JavaScript practice exercises, you’ll get the chance to be given a problem, have a go at solving it and then run through a possible solution to check your own.

JavaScript for beginners can be a bit of a stab in the dark to know whether your code is correct and the truth is that, for most javascript problems, there isn’t a right or wrong way of doing it.

But for some JavaScript practice problems, there is usually a short solution which can be achieved with JavaScript function and that is generally the aim of these JavaScript practice exercises for beginners.

It can also be good for you to see someone else break down a problem and code it in JavaScript and compare it with your own approach to a problem.

34 thoughts on “JavaScript Practice Exercises For Beginners: Beginner Exercises Part 1

  1. i started to take online free courses for beginners but those excersies are so hard…. And many people who are in thsoe courses are pretty good, i don't believe that they are learning coding only a week or two.

  2. Teacher, i resolved the exersice #3 (JS program to replace every character in a given string with the following in the alphabet ) using 2 for loops — to many lines of code ? 🙁 What if i do that in a interview ?

    function replaceCharacter(letter, alphabet) {
    for(let i = 0; i<= alphabet.length – 1; i++) {
    if(letter === alphabet[i]) {
    return alphabet[i+1];

    function replaceText(text) {
    result = '';
    for(let i = 0; i <= text.length – 1; i++) {
    result += replaceCharacter(text[i], 'abcdefghijklmnopqrstuvwxyz');
    return result;

  3. Hey… Can you explain to me why this isn't working
    let replace = (str) => {
    return str
    .map((char) => {
    String.fromCharCode(char.charCodeAt(0) + 1);


    Comes out empty and yes i'm aware it's not the same code as yours i was just trying it out on my own . Maybe im not thinking about a rule ?? Thanks for your help.

  4. This was really nice and helpful! And the font size was more than big enough to be read, that is certainly appreciated. Will continue tomorrow with the next video.
    I confess I got a bit confused with the map() on Exercise 3: the "String.fromCharCode" and the "charCodeAt" together.
    Would have loved to have it explained method by method, showing output.
    Other than that, happy with what I learned today! Thanks!

    PS: The pdf containing the exercises is neatly presented as well!

  5. Where would I have gained the base for the exercises? … I've been watching other tutorials but they just seem to explain what a Boolean or a String is .. nothing substantial … any help would be appreciated. Thanks.

  6. This is immensely helpful. I see a lot of tutorials for beginners using outdated notation, but I feel it is really important to get used to ES6 right from the initial stage.
    One question: wouldn't it be enough to declare the function without the "const" before the function name?

  7. current date:

    let currentDate = (date = new Date()) =>

    `${date.getDate()}/${date.getMonth() + 1}/${date.getFullYear()}`;


  8. Exercise 3 , an approach for newbies like me 😀

    /* Convert from String to Array as Strings are immutable
    Do the necessary incrementation
    Convert from Array to String
    Display String

    function incrementCharsFromString(str) {

    let arrayMode = Array.from(str)
    for (let i = 0; i < arrayMode.length; i++) {

    arrayMode[i] = arrayMode[i].charCodeAt() + 1
    arrayMode[i] = String.fromCharCode(arrayMode[i])

    // console.log(arrayMode)
    let str2 = arrayMode.join('')

    incrementCharsFromString('try me')

  9. Code for file extension:

    let fileName = "myDreamCar.min.js";

    let indexNumber = fileName.lastIndexOf(".");
    let extensionName = fileName.slice(indexNumber+1);

    document.write(extensionName );

  10. yes sir, i was looking for a test of javaxcript to test my self how muhc i have prepared for javascript, i am 18 year old and i have learned html 100%, python 50% , javascript 60%

  11. My solution to the last one was this one:

    function add(word){




    console.log('new!' + word)



    I don't know if it's good because I'm just getting started. Hope anyone can tell me (:

  12. i did ex 5 like this :l

    const addNewStr=(str)=>{


    return str



    return `New! ${str}`



    console.log(addNewStr('New! world'));

  13. exercise 5:
    your code doesn't meet the last condition: " If the given string begins with "New!" already then return the original string"
    I did:
    function addNew(str) {
    let b = str.replace('New!', '')
    } else {
    let a1 = 'New' + ' ' + str;

  14. i tried to download the exercises it went to my junk folder then i took it out. put in my archives then clicked to recieve then e-mail disappeared 🙁

  15. Hello, I am new to JS and I have tried your exercises and made programs. Your programs are to tough for me to understand because I haven't learnt those things yet but still have a look at my code and tell me if there are any flaws. Its working for me and I really enjoyed doing these exercises. main problem I have is "return and console.log" I don't know in what situation we use each of them.

    // EXERCISE 1: If input or its sum is equal to 100 return 100

    function eqTo100(x, y){

    if((x == 100) || (y == 100) || (x + y == 100)){

    return true;

    } else{

    return false;



    eqTo100(23, 77);

    // EXERCISE 2: Get the file extension name

    filename = "exercise.jkjk.js"


    // EXERCISE 3: Get the alphabet following the "x"

    var alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];

    function folAlp(b){

    var a = alphabets.indexOf(b);

    return alphabets[a + 1];



    // EXERCISE 4: Get the current date

    function currentDate([day, month, year]){

    console.log(day + "/" + month + "/" + year);


    currentDate([9, 9, 2020]);

    // EXERCISE 5: Add a "New!" in front of a string and it is already there then return orignal

    function addNew(str){


    return str;


    return "New! " + str;



    addNew("Hi I am cat");

    addNew("New! Hi I am cat");

Leave a Reply

Your email address will not be published. Required fields are marked *