# Knowledge Check - JavaScript in the browser

1. **In the following code, the type attribute can be omitted.**
    
    ```xml
    <script type="text/javascript">
        //Comment
    </script>
    ```
    
    * <mark>true</mark>
        
    * false
        
2. **What does the document variable return in JavaScript?**
    
    ```javascript
    console.log(document);
    ```
    
    * The entire body tag of the webpage in the browser's memory, as a JavaScript object.
        
    * <mark>The entire webpage in the browser's memory, as a JavaScript object.</mark>
        
    * The HTML code of the downloaded webpage, as a JavaScript string.
        
3. **What does the following function return?**
    
    ```javascript
    getElementById('main-heading')
    ```
    
    * It doesn't return anything.
        
    * All elements that have the class attribute with a value main-heading
        
    * <mark>The first element that has the id attribute with a value main-heading</mark>
        
    * The last element that has the id attribute with a value main-heading
        
4. **After the following code is run, what will happen when the user clicks on a p element in the browser?**
    
    ```javascript
    document.querySelector('h1').addEventListener('click', function() { 
        console.log('clicked');
    });
    ```
    
    * 'clicked' is printed to the console log.
        
    * <mark>Nothing.</mark>
        
5. **What will be printed when the following code runs?**
    
    ```javascript
    var result = {
        value: 7
    };
    console.log(JSON.stringify(result));
    ```
    
    * {}
        
    * {value: 7}
        
    * <mark>{"value": 7}</mark>
