Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 89 additions & 5 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,115 @@
function getLine(length) {
// TODO - write method definition here
var stars = "";
for (var starLength=0; starLength < length; starLength++) {
stars = stars + "*";
}
return stars;
}



function getBox(width, height) {
// TODO - write method definition here
var stars = "";
for(rows = 0; rows < height; rows++) {
for (columns = 0; columns < width; columns++) {
stars += "*";
}
stars += "\n";
}
return stars;
}



function getBottomLeftTriangle(length) {
// TODO - write method definition here
var stars = "";
for(i = 1; i <= length; i++) {
for (j = 0; j < i; j++) {
stars += "*";
}
if (i != length) {
stars += "\n";
}
}
return stars;
}


function getUpperLeftTriangle(length) {
// TODO - write method definition here
var stars = "";
for(i = length; i >= 1; i--) {
if (i!=length) {
stars += "\n";
}
for (j = 1; j <= i ; j++) {
stars += "*";
}
}
return stars;
}



function getPyramid(length) {
// TODO - write method definition here
var stars = "";
var spacing = length;
var newPyramid = true;
for (i = 1; i <= length; i++) {
for (j = 0; j < spacing -1; j++) {
stars += " ";
}
for (k = 1; k <= i; k++) {
if (i == 1 && k==1 && newPyramid) {
stars += "*";
spacing--;
if (length >= 3) {
stars += " ";
}
} else {
stars += "**";
spacing--;
}
}
if (i != length) {
if (!newPyramid) {
stars=stars.substring(0, stars.length - 1);
}
for (j = 0; j < length -1; j++) {
stars += " ";

stars += "\n";
newPyramid = false;
break;
}
}
}
if (stars.indexOf("*")) {
stars=stars.substring(0, stars.length - 1);
}
return stars;
}


function getCheckerboard(width, height) {
// TODO - write method definition here
var stars = "";
var pyrHeight;
for (pyrHeight = 1; pyrHeight <= height; pyrHeight++) {
if (width < 3){
if (pyrHeight % 2 != 0) {
stars += " *";
} else {
stars += "* ";
}
}
if (width >= 3) {
if (pyrHeight % 2 != 0) {
stars += " * ";
} else {
stars += "* *";
}
}
stars +="\n";
}
return stars;
}
52 changes: 52 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
<!DOCTYPE html>

<html lang="en">



<!-- ----------------------------------------------------------------- -->

<!-- ----------------------------------------------------------------- -->

<!-- ----------------------------------------------------------------- -->

<head> <!-- header begins here -->

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="description" content="">

<meta name="author" content="">



<link href="./assets/css/style.css" rel="stylesheet">

<script type="text/javascript" src="./assets/js/utils.js"></script>

<script type="text/javascript" src="./assets/js/shapes.js"></script>

<script type="text/javascript" src="./assets/js/header-functions.js"></script>



</head> <!-- header ends here -->

<!-- ----------------------------------------------------------------- -->

<!-- ----------------------------------------------------------------- -->

<!-- ----------------------------------------------------------------- -->


Expand All @@ -26,28 +46,60 @@





















<!-- ---------------------------------------------------------------------------------- -->

<!-- ---------------------------------------------------------------------------------- -->

<!-- ---------------------------------------------------------------------------------- -->

<body> <!-- body begins here -->



<!-- ====================================================== -->

<!-- ====================================================== -->

<footer>

<!-- footer of page begins here -->

<script type="text/javascript" src="./assets/js/footer-functions.js"></script>

</footer> <!-- footer of page ends here -->

<!-- ====================================================== -->

<!-- ====================================================== -->



</body>

<!-- ---------------------------------------------------------------------------------- -->

<!-- ---------------------------------------------------------------------------------- -->

<!-- ---------------------------------------------------------------------------------- -->



</html>