Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Figure JS</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
216 changes: 216 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
const getSquare = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
str += '*';
}
str += '\n';
}

console.log(str);
}

const getSquareEmpty = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
if (i === 0 || i === size - 1 || j === 0 || j === size - 1) {
str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getTriangleOne = size => {
let str = '';

for (let i = size; i > 0; i--) {
for (let j = 0; j < size + 1; j++) {
if (j >= i) {
str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}
Comment on lines +31 to +46
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other variant:

const getTriangleOne = size => {
    let str = '';

    for (let i =0; i < size; i++) {
        for (let j = 0; j < size; j++) {
            if (j >= size - 1 - i) {
                str += '*';
            } else {
                str += ' ';
            }
        }
        str += '\n';
    }

    console.log(str);
}


const getTriangleTwo = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
if (j <= i) {
str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getTriangleThree = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
if (i <= j) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other variant: if (j >= i) {

str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getTriangleFour = size => {
let str = '';

for (let i = size; i > 0; i--) {
for (let j = 0; j < size + 1; j++) {
if (i > j) {
str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}
Comment on lines +82 to +97
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other variant:

const getTriangleFour = size => {
    let str = '';

    for (let i = 0; i < size; i++) {
        for (let j = 0; j < size; j++) {
            if (j <= size - 1 - i) {
                str += '*';
            } else {
                str += ' ';
            }
        }
        str += '\n';
    }

    console.log(str);
}


const getTriangleEmpOne = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = size; 0 < j; j--) {
if (j - 1 === i || j === 1 || i === size - 1) {
Comment on lines +102 to +104
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (let i = 0; i < size; i++) {
        for (let j = 0; j < size; j++) {
            if (i === size - 1 || j === size - 1 || j === size - 1 - i) {

str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getTriangleEmpTwo = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
if (j === i || j === 0 || i === size - 1) {
str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getTriangleEmpThree = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
if (j === i || i === 0 || j === size - 1) {
str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getTriangleEmpFour = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = size; 0 < j; j--) {
if (j - 1 === i || i === 0 || j === size) {
Comment on lines +153 to +155
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    for (let i = 0; i < size; i++) {
        for (let j = 0; j < size; j++) {
            if (i === 0 || j === 0 || i === size - 1 - j) {

str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getX = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
if (j === i || i === size - j - 1) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (j === i || j === size - i - 1) {

str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getEmpSandHour = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
if (j === i || i === size - j - 1 || i === 0 || i === size - 1) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j === size - 1 - i

str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}

const getSandHour = size => {
let str = '';

for (let i = 0; i < size; i++) {
for (let j = 0; j < size; j++) {
if ((j < i) && (i >= size - j) || (j > i) && (j < size - i) || j === i || i === size - 1 || i === size - j - 1) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (j >= i && j <= size - 1 - i || j >= size - 1 - i && j <= i) {

str += '*';
} else {
str += ' ';
}
}
str += '\n';
}

console.log(str);
}