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

Create index.js #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
72 changes: 72 additions & 0 deletions submissions/OleksiiAnoshkin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { print } from './js/lib.js';

"use strict";

/* Refer to https://github.com/OleksiyRudenko/a-tiny-JS-world for the task details
Complete the below for code reviewers' convenience:

Code repository: https://github.com/oleksii-anoshkin/a-tiny-JS-world
Web app: _put project's github pages URL here_
*/

// ======== OBJECTS DEFINITIONS ========
// Define your objects here

class Objects {
constructor(object, name, gender, hands, legs, phrase, friends) {
this.object = object,
this.name = name,
this.gender = gender,
this.hands = hands,
this.legs = legs,
this.saying = phrase,
this.friends = friends
};

printObj() {
let str = ``;
let i = 1;

for (const key in this) {
if (i === 7) {
str += `${this[key]}`;
continue;
};

str += `${this[key]}; `;
i += 1;
};

return str;
};
};

const man = new Objects("human", "Oleksii", "male", 2, 2, "Hello! My name's Oleksii! Nice to meet you!", "Julia, Jack, Lili");
const woman = new Objects("human", "Julia", "female", 2, 2, "Hello! My name's Julia! Nice to meet you!", "Oleksii, Jack, Lili");
const dog = new Objects("animal", "Jack", "male", 0, 4, "Woof-woof!", "Oleksii, Julia, Lili");
const cat = new Objects("animal", "Lili", "female", 0, 4, "Meow-meow!", "Oleksii, Julia, Jack");
const catWoman = new Objects("human", "Mia", "female", 2, 2, cat.saying, "Lili");

// ======== OUTPUT ========

[man, woman, dog, cat, catWoman].forEach(obj => print(`${obj.printObj()}`, 'div'));

// print(`<strong></strong>`, 'div');

/* Use print(message) for output.
Default tag for message is <pre>. Use print(message,'div') to change containing element tag.

Message can contain HTML markup. You may also tweak index.html and/or styles.css.
However, please, REFRAIN from improving visuals at least until your code is reviewed
so code reviewers might focus on a single file that is index.js.
*/

/* Print examples:
print('ABC');
print('<strong>ABC</strong>');
print('<strong>ABC</strong>', 'div');

print('human; John; male; 2; 2; Hello world!; Rex, Tom, Jenny');
print('human; <strong>John</strong>; male; 2; 2; <em>Hello world!</em>; Rex, Tom, Jenny');
print('human; <strong>John</strong>; male; 2; 2; <em>Hello world!</em>; Rex, Tom, Jenny', 'div');
*/