Javascript Text loop on click











up vote
-6
down vote

favorite












some Javascript code
that writes ten times the sentence “I know a bit of JavaScript” after clicking on a text within an tag. Your code should use a for loop or a while loop and if statements. You must use a function to write the sentence.










share|improve this question






















  • The posted question does not appear to include any attempt at all to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific roadblock you're running into a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour.
    – CertainPerformance
    Nov 20 at 5:44










  • Why does this seem like word-for-word homework instructions?
    – vol7ron
    Nov 20 at 5:46










  • Literally just someone's homework...
    – Jacin Tattersall
    Nov 20 at 5:48










  • you can try that yourself. It just takes the basics of JavaScript.If you don't try this simple exercise then how you are going to learn programming
    – RopAli Munshi
    Nov 20 at 7:36















up vote
-6
down vote

favorite












some Javascript code
that writes ten times the sentence “I know a bit of JavaScript” after clicking on a text within an tag. Your code should use a for loop or a while loop and if statements. You must use a function to write the sentence.










share|improve this question






















  • The posted question does not appear to include any attempt at all to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific roadblock you're running into a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour.
    – CertainPerformance
    Nov 20 at 5:44










  • Why does this seem like word-for-word homework instructions?
    – vol7ron
    Nov 20 at 5:46










  • Literally just someone's homework...
    – Jacin Tattersall
    Nov 20 at 5:48










  • you can try that yourself. It just takes the basics of JavaScript.If you don't try this simple exercise then how you are going to learn programming
    – RopAli Munshi
    Nov 20 at 7:36













up vote
-6
down vote

favorite









up vote
-6
down vote

favorite











some Javascript code
that writes ten times the sentence “I know a bit of JavaScript” after clicking on a text within an tag. Your code should use a for loop or a while loop and if statements. You must use a function to write the sentence.










share|improve this question













some Javascript code
that writes ten times the sentence “I know a bit of JavaScript” after clicking on a text within an tag. Your code should use a for loop or a while loop and if statements. You must use a function to write the sentence.







javascript loops for-loop if-statement while-loop






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 5:44









dioworld

1




1












  • The posted question does not appear to include any attempt at all to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific roadblock you're running into a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour.
    – CertainPerformance
    Nov 20 at 5:44










  • Why does this seem like word-for-word homework instructions?
    – vol7ron
    Nov 20 at 5:46










  • Literally just someone's homework...
    – Jacin Tattersall
    Nov 20 at 5:48










  • you can try that yourself. It just takes the basics of JavaScript.If you don't try this simple exercise then how you are going to learn programming
    – RopAli Munshi
    Nov 20 at 7:36


















  • The posted question does not appear to include any attempt at all to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific roadblock you're running into a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour.
    – CertainPerformance
    Nov 20 at 5:44










  • Why does this seem like word-for-word homework instructions?
    – vol7ron
    Nov 20 at 5:46










  • Literally just someone's homework...
    – Jacin Tattersall
    Nov 20 at 5:48










  • you can try that yourself. It just takes the basics of JavaScript.If you don't try this simple exercise then how you are going to learn programming
    – RopAli Munshi
    Nov 20 at 7:36
















The posted question does not appear to include any attempt at all to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific roadblock you're running into a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour.
– CertainPerformance
Nov 20 at 5:44




The posted question does not appear to include any attempt at all to solve the problem. StackOverflow expects you to try to solve your own problem first, as your attempts help us to better understand what you want. Please edit the question to show what you've tried, so as to illustrate a specific roadblock you're running into a Minimal, Complete, and Verifiable example. For more information, please see How to Ask and take the tour.
– CertainPerformance
Nov 20 at 5:44












Why does this seem like word-for-word homework instructions?
– vol7ron
Nov 20 at 5:46




Why does this seem like word-for-word homework instructions?
– vol7ron
Nov 20 at 5:46












Literally just someone's homework...
– Jacin Tattersall
Nov 20 at 5:48




Literally just someone's homework...
– Jacin Tattersall
Nov 20 at 5:48












you can try that yourself. It just takes the basics of JavaScript.If you don't try this simple exercise then how you are going to learn programming
– RopAli Munshi
Nov 20 at 7:36




you can try that yourself. It just takes the basics of JavaScript.If you don't try this simple exercise then how you are going to learn programming
– RopAli Munshi
Nov 20 at 7:36












1 Answer
1






active

oldest

votes

















up vote
0
down vote













I will not give you any code since this sounds like homework, but how about breaking the question down and googling every step of it.



Lets break it down:




  1. Write ten times a sentace. Your code should use a loop.
    Lets check what the JavaScript docs say about while loops :https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while


  2. Clicking on a text within an tag:
    Lets check what the JavaScript docs say about the click event:
    https://developer.mozilla.org/en-US/docs/Web/Events/click


  3. You muse use a function to write the sentance
    Lets check what the JavaScript docs say about functions
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions



So take it piece by piece. It doesn't have to to all the right things at once. Just break it down.




  1. Try to make a while loop do something 10 times. Just to console.log('stuff') out. Just so that you see something happening 10 times.


  2. Try to make a onClick event console.log('I got clicked'), just to make sure you have your event



  3. Try to make a function do something.



    When you have a function that does something, a loop that runs 10 times and an onClick event that fires then its just a matter of putting it all together.








share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386909%2fjavascript-text-loop-on-click%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    I will not give you any code since this sounds like homework, but how about breaking the question down and googling every step of it.



    Lets break it down:




    1. Write ten times a sentace. Your code should use a loop.
      Lets check what the JavaScript docs say about while loops :https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while


    2. Clicking on a text within an tag:
      Lets check what the JavaScript docs say about the click event:
      https://developer.mozilla.org/en-US/docs/Web/Events/click


    3. You muse use a function to write the sentance
      Lets check what the JavaScript docs say about functions
      https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions



    So take it piece by piece. It doesn't have to to all the right things at once. Just break it down.




    1. Try to make a while loop do something 10 times. Just to console.log('stuff') out. Just so that you see something happening 10 times.


    2. Try to make a onClick event console.log('I got clicked'), just to make sure you have your event



    3. Try to make a function do something.



      When you have a function that does something, a loop that runs 10 times and an onClick event that fires then its just a matter of putting it all together.








    share|improve this answer

























      up vote
      0
      down vote













      I will not give you any code since this sounds like homework, but how about breaking the question down and googling every step of it.



      Lets break it down:




      1. Write ten times a sentace. Your code should use a loop.
        Lets check what the JavaScript docs say about while loops :https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while


      2. Clicking on a text within an tag:
        Lets check what the JavaScript docs say about the click event:
        https://developer.mozilla.org/en-US/docs/Web/Events/click


      3. You muse use a function to write the sentance
        Lets check what the JavaScript docs say about functions
        https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions



      So take it piece by piece. It doesn't have to to all the right things at once. Just break it down.




      1. Try to make a while loop do something 10 times. Just to console.log('stuff') out. Just so that you see something happening 10 times.


      2. Try to make a onClick event console.log('I got clicked'), just to make sure you have your event



      3. Try to make a function do something.



        When you have a function that does something, a loop that runs 10 times and an onClick event that fires then its just a matter of putting it all together.








      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        I will not give you any code since this sounds like homework, but how about breaking the question down and googling every step of it.



        Lets break it down:




        1. Write ten times a sentace. Your code should use a loop.
          Lets check what the JavaScript docs say about while loops :https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while


        2. Clicking on a text within an tag:
          Lets check what the JavaScript docs say about the click event:
          https://developer.mozilla.org/en-US/docs/Web/Events/click


        3. You muse use a function to write the sentance
          Lets check what the JavaScript docs say about functions
          https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions



        So take it piece by piece. It doesn't have to to all the right things at once. Just break it down.




        1. Try to make a while loop do something 10 times. Just to console.log('stuff') out. Just so that you see something happening 10 times.


        2. Try to make a onClick event console.log('I got clicked'), just to make sure you have your event



        3. Try to make a function do something.



          When you have a function that does something, a loop that runs 10 times and an onClick event that fires then its just a matter of putting it all together.








        share|improve this answer












        I will not give you any code since this sounds like homework, but how about breaking the question down and googling every step of it.



        Lets break it down:




        1. Write ten times a sentace. Your code should use a loop.
          Lets check what the JavaScript docs say about while loops :https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/while


        2. Clicking on a text within an tag:
          Lets check what the JavaScript docs say about the click event:
          https://developer.mozilla.org/en-US/docs/Web/Events/click


        3. You muse use a function to write the sentance
          Lets check what the JavaScript docs say about functions
          https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions



        So take it piece by piece. It doesn't have to to all the right things at once. Just break it down.




        1. Try to make a while loop do something 10 times. Just to console.log('stuff') out. Just so that you see something happening 10 times.


        2. Try to make a onClick event console.log('I got clicked'), just to make sure you have your event



        3. Try to make a function do something.



          When you have a function that does something, a loop that runs 10 times and an onClick event that fires then its just a matter of putting it all together.









        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 3 at 21:57









        Bergur

        814510




        814510






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386909%2fjavascript-text-loop-on-click%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python