Part A - Leap Years Write a function that accepts a year, and works out whether if a given year is a leap year (returning true if it is a leap year and false if it isn't). A normal year has 365 days, leap years have 366, with an extra day in February. This is how to work out whether if a particular year is a leap year: A year is a leap year if it is evenly divisible by 4; except if that year is also evenly divisible by 100 but not 400; Call the function and with the result use a string template literal to print out a sentence including the year, and if it is a leap year or not. Part B - Pyramid Building Write a function that accepts a number (the height of the pyramid), and creates an array of strings where each string represents a level in the pyramid. Each block in the pyramid is represented by the @ character. The array should be returned from the function and printed to the console. So for example a pyramid of 3 levels would look like: [ ] II II @ II II @@@ 'CEEEE" and a pyramid with 5 levels would look like: [ II II @ @ee II II ] eeeee II "eeeeeeeee" Micro

COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
1st Edition
ISBN:9780357392676
Author:FREUND, Steven
Publisher:FREUND, Steven
Chapter3: Working With Large Worksheets, Charting, And What-if Analysis
Section: Chapter Questions
Problem 2.2EYK
icon
Related questions
Question

Finally, your going to write several small javascript functions to practice with javascript core programming (basically just using javascript as a normal scripting language). For each section you can hardcode input values, and all output should go to console (we'll worry about the actual web page on Assignment 4). You can complete these all in one HTML file, or create one file for each part. 

Part A - Leap Years
Write a function that accepts a year, and works out whether if a given year is a leap year (returning true if it is a
leap year and false if it isn't). A normal year has 365 days, leap years have 366, with an extra day in February.
This is how to work out whether if a particular year is a leap year:
A year is a leap year if it is evenly divisible by 4;
except if that year is also evenly divisible by 100 but not 400;
Call the function and with the result use a string template literal to print out a sentence including the year, and if
it is a leap year or not.
Part B - Pyramid Building
Write a function that accepts a number (the height of the pyramid), and creates an array of strings where each
string represents a level in the pyramid. Each block in the pyramid is represented by the @ character. The array
should be returned from the function and printed to the console.
So for example a pyramid of 3 levels would look like:
[
]
II
II
@
II
II
@@@
'CEEEE"
and a pyramid with 5 levels would look like:
[
II
II
@
@ee
II
II
]
eeeee
II
"eeeeeeeee"
Micro
Transcribed Image Text:Part A - Leap Years Write a function that accepts a year, and works out whether if a given year is a leap year (returning true if it is a leap year and false if it isn't). A normal year has 365 days, leap years have 366, with an extra day in February. This is how to work out whether if a particular year is a leap year: A year is a leap year if it is evenly divisible by 4; except if that year is also evenly divisible by 100 but not 400; Call the function and with the result use a string template literal to print out a sentence including the year, and if it is a leap year or not. Part B - Pyramid Building Write a function that accepts a number (the height of the pyramid), and creates an array of strings where each string represents a level in the pyramid. Each block in the pyramid is represented by the @ character. The array should be returned from the function and printed to the console. So for example a pyramid of 3 levels would look like: [ ] II II @ II II @@@ 'CEEEE" and a pyramid with 5 levels would look like: [ II II @ @ee II II ] eeeee II "eeeeeeeee" Micro
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage