SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: bool

  1. #1
    SitePoint Member
    Join Date
    Dec 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    bool

    Hello!
    Is with x==8 answer authomatically "set" to bool?

    Code:
    <!DOCTYPE html>
    <html>
    <body>
    
    <p>Given that x=5, return the value of the comparison x==8.</p>
    <button onclick="myFunction()">Try it</button>
    
    <p id="demo"></p>
    
    <script>
    function myFunction()
    {
    var x=99;
    document.getElementById("demo").innerHTML=x==8;
    }
    </script>
    
    </body>
    </html>

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,286
    Mentioned
    121 Post(s)
    Tagged
    1 Thread(s)
    This looks like homework. Did you try your demo page in a browser to see what happens?
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    SitePoint Member
    Join Date
    Dec 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. I am complete beginner. We never said it shoudl be bool, it "concluded " it automatilaccly, obviously...didnt it???


    I mean, we never wrote word "bool" in this example, but it "knows" it should be written true or false...itis from w3school...i tried...

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by mkjs View Post
    Yes. I am complete beginner.
    Don't take this the wrong way, but don't you think it might be an idea to read up on some of the basics first?

    Quote Originally Posted by mkjs View Post
    it is from w3school
    W3Schools is not the best place to learn JavaScript.
    Try this, this or this instead:

  5. #5
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,003
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Also, does it help to think of your code like this:

    Code:
    var x=99;
    document.getElementById("demo").innerHTML=(x===8);
    => false
    
    document.getElementById("demo").innerHTML=(x===99);
    => true


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •