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

TJSW without OOP (Task#8 of Stage0) #737

Open
wants to merge 3 commits into
base: main
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
52 changes: 52 additions & 0 deletions submissions/ivan-chukhalo/tjw-without-oop/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
function getInfo(incomeCreature) {
let consolidatedInfo = [];
Object.getOwnPropertyNames(incomeCreature).forEach((elArr) => {
consolidatedInfo.push(incomeCreature[elArr]);
});
return consolidatedInfo.join("; ");
}

const janLevinson = {
name: "Jan Levinson",
sex: "Female",
friends: "no friends",
species: "Human",
saying: '"You are not he first one!"',
lags: 2,
hands: 2,
};

const michaelScott = {
name: "Michael Scott",
sex: "Male",
friends: "Jan Levinson is a friend",
species: "Human",
saying: '"Thats what she said!"',
lags: 2,
hands: 2,
};

const theirDog = {
name: "Pesyk",
sex: "Male",
friends: "Jan Levinson is a friend",
species: "Dog",
saying: "Woof",
lags: 4,
hands: 0,
};

const theirCat = {
name: "Kytsia",
sex: "Female",
friends: "Michael Scott is a friend",
species: "Cat",
saying: "Whats up, buddy? I mean meow.",
lags: 4,
hands: 0,
};

const listOfCreatures = [janLevinson, michaelScott, theirDog, theirCat];
listOfCreatures.forEach((el) => {
print(getInfo(el));
});