Skip to content

Commit

Permalink
Merge pull request #564 from avantikachittari/main
Browse files Browse the repository at this point in the history
Commit to add new version of nested conditionals hw with better reada…
  • Loading branch information
jm1021 authored Nov 5, 2024
2 parents 829bf9e + 4a996a7 commit 8bc8850
Showing 1 changed file with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,36 @@
}
},
"source": [
"<h2><span style=\"font-family: Ariel; color:#94c4ff\">Homework - Integers, Booleans, AND Random</span></h2>\n",
"<h2><span style=\"font-family: Ariel; color:#94c4ff\">Homework - Nested Conditionals</span></h2>\n",
"\n",
"Objective:\n",
"## Objective:\n",
"Write a JavaScript program that randomly assigns a student grade level (from 0 to 12) and outputs the school level the student would be in (kindergarten, elementary, middle, or high school). The program also identifies if the student is in their last year at their current school level.\n",
"\n",
"Instructions:\n",
"## Instructions:\n",
"\n",
"Open a JavaScript file (e.g., schoolLevel.js).\n",
"1. Open a JavaScript file (e.g., schoolLevel.js).\n",
"\n",
"Generate a Random Grade:\n",
"2. Generate a Random Grade:\n",
" - Use Math.random() to generate a random number between 0 to 1 and multiply it by 12, which will represent the student’s grade.\n",
" - Round the number to the nearest whole number using Math.round().\n",
" - Store this number in a variable called grade.\n",
" - Print the grade to the console with a message such as, \"You are in grade ___.\"\n",
"\n",
"Use Math.random() to generate a random number between 0 to 1 and multiply it by 12, which will represent the student’s grade.\n",
"Round the number to the nearest whole number using Math.round().\n",
"Store this number in a variable called grade.\n",
"Print the grade to the console with a message such as, \"You are in ___ grade.\"\n",
"Determine the School Level:\n",
"3. Determine the School Level:\n",
" Use if statements to check the value of grade and print which school level the student is in:\n",
" - Kindergarten for grade 0.\n",
" - Elementary School for grades 1–5.\n",
" - Middle School for grades 6–8.\n",
" - High School for grades 9–12.\n",
"\n",
"Use if statements to check the value of grade and print which school level the student is in:\n",
"Kindergarten for grade 0\n",
"Elementary School for grades 1–5\n",
"Middle School for grades 6–8\n",
"High School for grades 9–12\n",
"For each school level, add an additional check to see if the student is in their final year. If all is done correctly, it will print a message like this, “You will graduate this year from _____.”\n",
"\n"
"4. For each school level, add a nested additional check to see if the student is in their final year. If all is done correctly, it will print a message like this, “You will graduate this year from _____.”\n",
"\n",
"5. Sample Outputs:\n",
" - Sample 1:\n",
" - \"You are in grade 5.\"\n",
" - \"You will graduate this year from elementary school\"\n",
" - Sample 2:\n",
" - \"You are in grade 3.\""
]
},
{
Expand All @@ -62,7 +68,8 @@
}
},
"source": [
"- Booleans are a data type that can only have two different values True or Flase. \n",
"Extra information:\n",
"- Booleans are a data type that can only have two different values - True or Flase. You can use boolean flag to identify if student is in final year.\n",
"- Random generates random values with unpredictable results, usually within a specified range such as 0-1"
]
}
Expand Down

0 comments on commit 8bc8850

Please sign in to comment.