title: Javascript function program
body: <p>Could Someone Pls Help Checkout this? I still can submit this even after passing all five test. </p>
  
  <p>Question</p>
  
  <p>According to the description of R-rated films: Children under 17 require an accompanying parent or adult guardian (age 21 or older) and adults 25 years and under must show ID. And children under the age of 6 are not allowed in after 6:00pm.</p>
  
  <p>Deadpool is an R-rated movie.</p>
  
  <p>Write a JavaScript function named canIWatch that will take age as a parameter.</p>
  
  <p>If the age is less than 6, return You are not allowed to watch Deadpool after 6.00pm.</p>
  
  <p>If the age is 6 or more but less than 17, return You must be accompanied by a guardian who is 21 or older.</p>
  
  <p>If the age is 17 or more but less than 25, return You are allowed to watch Deadpool, right after you show some ID.</p>
  
  <p>If the age is 25 or greater, return Yay! You can watch Deadpool with no strings attached!.</p>
  
  <p>If the age is invalid, return Invalid age.</p>
  
  <p>Unittest</p>
  
  <pre><code>describe('canIWatch tests', function () {
  
    it('Should return the appropriate message for age less than 6', function () {
      expect(canIWatch(5)).toEqual('You are not allowed to watch Deadpool after 6.00pm.');
    });
  
    it('Should return the appropriate message for age less than 17', function () {
      expect(canIWatch(15)).toEqual('You must be accompanied by a guardian who is 21 or older.');
    });
  
    it('Should return the appropriate message for age less than 25', function () {
      expect(canIWatch(20)).toEqual('You are allowed to watch Deadpool, right after you show some ID.');
    });
  
    it('Should return the appropriate message for age above 25 than 6', function () {
      expect(canIWatch(30)).toEqual('Yay! You can watch Deadpool with no strings attached!');
    });
  
    it('should return an appropriate message if provided age is invalid', function () {
      expect(canIWatch(-1)).toEqual('Invalid age.');
    });
  });
  </code></pre>
  
  <p>Here is my solution:</p>
  
  <pre><code>function canIWatch(age) {
  
      if(age &gt; 0 &amp;&amp; age &lt; 6) {
  
          return "You are not allowed to watch Deadpool after 6.00pm.";
      }
  
      else if(age &gt; 6 &amp;&amp; age &lt; 17) {
  
          return "You must be accompanied by a guardian who is 21 or older.";
      }
      else if(age &gt; 17 &amp;&amp; age &lt; 25) {
          return "You are allowed to watch Deadpool, right after you show some ID.";
      }
      else if(age &gt; 25 &amp;&amp; age &lt; 200) {
  
          return "Yay! You can watch Deadpool with no strings attached!";
      }
      else {
          return "Invalid age.";
      }
  }
  </code></pre>