Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I need help solving this problem. I am confused

    Write a function named sleepCheck that takes the parameter numHours
    Inside the function, write an if statement where if the number of hours of sleep is greater than or equal to 8, the computer will return "You're getting plenty of sleep! Maybe even too much!";.
    Otherwise (else) if the number of hours of sleep is less than 8, have the computer return "Get some more shut eye!";

    Then call the function with different hours of sleep

    Call the function with 10 hours of sleep, like this: sleepCheck(10);
    Call the function with 5 hours of sleep.
    Call the function with 8 hours of sleep.

  • #2
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,302
    Thanks
    28
    Thanked 276 Times in 270 Posts
    Quote Originally Posted by bmmedia View Post
    Write a function named sleepCheck that takes the parameter numHours
    Dear confused, I have kindly made an attempt to address your issue:

    Code:
    <!doctype html>
    <html lang="en">
    	<head>
    		<meta charset="utf-8">
    		<title>Demo</title>
    	</head>
    	<body>
    		<script>
    			"use strict";
    			var paragraph = document.createElement("p");
    			var homework = true;
    			var userAttempts = 0;
    			function canAssist() {
    				if (userAttempts > 1) {
    					return true;
    				}
    				else {
    					return false;
    				}
    			}
    			paragraph.textContent = "\u263a"
    			if (homework && !canAssist()) {
    				paragraph.textContent = "\u2639";
    			}
    			document.body.appendChild(paragraph);
    		</script>
    	</body>
    </html>
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Tags for this Thread

    Posting Permissions

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