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
2 changes: 1 addition & 1 deletion assets/js/footer-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getBoxTests() {
function getBottomLeftTriangleTests() {
testGetBottomLeftTriangle("*", 1);
testGetBottomLeftTriangle("*\n**", 2);
testGetBottomLeftTriangle("*\n**\n**", 3);
testGetBottomLeftTriangle("*\n**\n***", 3);
}

function getUpperLeftTriangleTests() {
Expand Down
73 changes: 67 additions & 6 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,92 @@
function getLine(length) {
// TODO - write method definition here
var str = "";
for(var i = 0; i < length; i++){
str = str + "*";
}
return str;
}



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



function getBottomLeftTriangle(length) {
// TODO - write method definition here
var str = "";
for(var index = 1; index <= length; index++) {
for(var num = 0; num < index; num++) {
str = str + "*";
}
str = str + "\n";
}
return str.slice(0,-1);
}


function getUpperLeftTriangle(length) {
// TODO - write method definition here
var str = "";
for(var index = length; index >= 1; index--) {
for(var num = 0; num < index; num++) {
str = str + "*";
}
str = str + "\n";
}
return str.slice(0,-1);
}



function getPyramid(length) {
// TODO - write method definition here
var str = "";
for(var j = 1, i = 1, num = length-1; j <= length; j++, i=i+2, num--){
var temp = num;
while(temp > 0){
str = str + " ";
temp --;
}
temp = i;
while(temp > 0){
str = str + "*";
temp --;
}
temp = num;
while(temp > 0){
str = str + " ";
temp --;
}
str = str + "\n";
}
return str.slice(0,-1);
}


function getCheckerboard(width, height) {
// TODO - write method definition here
var str = "";
for(var i = 0; i < height; i++){
if(i%2 == 0)
var temp = 0;
else var temp = 1;
for(var j = 0; j < width; j++){
if(temp == 0) {
temp = 1;
str = str + " ";
continue;}
else {
str = str + "*";
temp = 0;
}
}
str = str + "\n";
}
return str.slice(0,-1);
}
31 changes: 0 additions & 31 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<!DOCTYPE html>
<html lang="en">

<!-- ----------------------------------------------------------------- -->
<!-- ----------------------------------------------------------------- -->
<!-- ----------------------------------------------------------------- -->
<head> <!-- header begins here -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -16,38 +12,11 @@
<script type="text/javascript" src="./assets/js/header-functions.js"></script>

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












<!-- ---------------------------------------------------------------------------------- -->
<!-- ---------------------------------------------------------------------------------- -->
<!-- ---------------------------------------------------------------------------------- -->
<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>