How to run JavaScript?












-2















In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed



<script type="text/javascript">


and hit enter, but I got error message




Uncaught Syntax error: Unexpected Token<




Why?










share|improve this question

























  • What are you trying to practice? We can run JavaScript code easy in console

    – Pramod Kharade
    Nov 21 '18 at 4:31






  • 1





    That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag </script>.

    – Amy
    Nov 21 '18 at 4:32


















-2















In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed



<script type="text/javascript">


and hit enter, but I got error message




Uncaught Syntax error: Unexpected Token<




Why?










share|improve this question

























  • What are you trying to practice? We can run JavaScript code easy in console

    – Pramod Kharade
    Nov 21 '18 at 4:31






  • 1





    That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag </script>.

    – Amy
    Nov 21 '18 at 4:32
















-2












-2








-2








In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed



<script type="text/javascript">


and hit enter, but I got error message




Uncaught Syntax error: Unexpected Token<




Why?










share|improve this question
















In Chrome, I right clicked and select "inspect", and then I went "Console" tab. I wanted to practice JavaScript, so I typed



<script type="text/javascript">


and hit enter, but I got error message




Uncaught Syntax error: Unexpected Token<




Why?







javascript google-chrome-devtools






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 5:26









Harsh Patel

1,67811229




1,67811229










asked Nov 21 '18 at 4:29









CathyCathy

124




124













  • What are you trying to practice? We can run JavaScript code easy in console

    – Pramod Kharade
    Nov 21 '18 at 4:31






  • 1





    That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag </script>.

    – Amy
    Nov 21 '18 at 4:32





















  • What are you trying to practice? We can run JavaScript code easy in console

    – Pramod Kharade
    Nov 21 '18 at 4:31






  • 1





    That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag </script>.

    – Amy
    Nov 21 '18 at 4:32



















What are you trying to practice? We can run JavaScript code easy in console

– Pramod Kharade
Nov 21 '18 at 4:31





What are you trying to practice? We can run JavaScript code easy in console

– Pramod Kharade
Nov 21 '18 at 4:31




1




1





That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag </script>.

– Amy
Nov 21 '18 at 4:32







That is a script tag, which is HTML. You can't run HTML in the console. That tag contains JavaScript, after the close of the tag in the question until the closing tag </script>.

– Amy
Nov 21 '18 at 4:32














2 Answers
2






active

oldest

votes


















1














The console defaults to run javascript so you need not specify



<script type="text/javascript">


this explicitly it understands so just try to run the javascript as it is and it should be working fine.






share|improve this answer
























  • Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?

    – Cathy
    Nov 23 '18 at 0:30





















0














Please use the following website for JS practice




https://jsfiddle.net




Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.



And <script> is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.






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',
    autoActivateHeartbeat: false,
    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%2f53405271%2fhow-to-run-javascript%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The console defaults to run javascript so you need not specify



    <script type="text/javascript">


    this explicitly it understands so just try to run the javascript as it is and it should be working fine.






    share|improve this answer
























    • Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?

      – Cathy
      Nov 23 '18 at 0:30


















    1














    The console defaults to run javascript so you need not specify



    <script type="text/javascript">


    this explicitly it understands so just try to run the javascript as it is and it should be working fine.






    share|improve this answer
























    • Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?

      – Cathy
      Nov 23 '18 at 0:30
















    1












    1








    1







    The console defaults to run javascript so you need not specify



    <script type="text/javascript">


    this explicitly it understands so just try to run the javascript as it is and it should be working fine.






    share|improve this answer













    The console defaults to run javascript so you need not specify



    <script type="text/javascript">


    this explicitly it understands so just try to run the javascript as it is and it should be working fine.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 21 '18 at 6:16









    Sundeep PiduguSundeep Pidugu

    39912




    39912













    • Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?

      – Cathy
      Nov 23 '18 at 0:30





















    • Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?

      – Cathy
      Nov 23 '18 at 0:30



















    Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?

    – Cathy
    Nov 23 '18 at 0:30







    Thanks for your help. I'm learning Javascript. Here I skipped <script type="text/javascript"> and just typed "document.write("Hello World!");", but I got "Undefined" returned in the console. So do I need to define anything before using the function?

    – Cathy
    Nov 23 '18 at 0:30















    0














    Please use the following website for JS practice




    https://jsfiddle.net




    Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.



    And <script> is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.






    share|improve this answer




























      0














      Please use the following website for JS practice




      https://jsfiddle.net




      Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.



      And <script> is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.






      share|improve this answer


























        0












        0








        0







        Please use the following website for JS practice




        https://jsfiddle.net




        Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.



        And <script> is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.






        share|improve this answer













        Please use the following website for JS practice




        https://jsfiddle.net




        Coming to your question, you can practice JS in Console but you don't need to tell browser that you want to run javascript it know by default.



        And <script> is a tag in HTML, read about it here https://www.w3schools.com/html/html_scripts.asp.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 '18 at 4:35









        GoldyGoldy

        348314




        348314






























            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405271%2fhow-to-run-javascript%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

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]