Daily Challenge (95 Part Series)
Welcome to Day 2 of our challenge series. Today, you’ll be using some clean and polished code to create a clean and polished diamond.
Our challenge comes from user @jayeshcp on CodeWars.
Your task is to return a string that displays a diamond shape on the screen using asterisk (“*”) characters.
The shape that the print method will return should resemble a diamond. A number provided as input will represent the number of asterisks printed on the middle line. The line above and below will be centered and will have two less asterisks than the middle line. This reduction will continue for each line until a line with a single asterisk is printed at the top and bottom of the figure.
nullif input is an even number or a negative number.
Note: JS and Python students must implement
diamond()method and return
null(JS) for invalid input.
Bonus points awarded for experimenting with any extra features.
Want to propose a challenge for a future post? Email email@example.com with your suggestions!