From eaed8827cc686fe8dd19f2095ad1b329133e794d Mon Sep 17 00:00:00 2001 From: Ivan Chukhalo Date: Sat, 1 Oct 2022 17:13:53 +0300 Subject: [PATCH 1/3] add tiny-js without using oop --- submissions/ivan-chukhalo/tjw-without-oop/index.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 submissions/ivan-chukhalo/tjw-without-oop/index.js diff --git a/submissions/ivan-chukhalo/tjw-without-oop/index.js b/submissions/ivan-chukhalo/tjw-without-oop/index.js new file mode 100644 index 0000000000..e69de29bb2 From 78107ade58fdb8a173e3b734bce4c732b9179268 Mon Sep 17 00:00:00 2001 From: Ivan Chukhalo Date: Sat, 1 Oct 2022 23:02:16 +0300 Subject: [PATCH 2/3] update --- .../ivan-chukhalo/tjw-without-oop/index.js | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/submissions/ivan-chukhalo/tjw-without-oop/index.js b/submissions/ivan-chukhalo/tjw-without-oop/index.js index e69de29bb2..7593efa230 100644 --- a/submissions/ivan-chukhalo/tjw-without-oop/index.js +++ b/submissions/ivan-chukhalo/tjw-without-oop/index.js @@ -0,0 +1,53 @@ +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, + }; + + print(getInfo(janLevinson)); + print(getInfo(michaelScott)); + print(getInfo(theirDog)); + print(getInfo(theirCat)); + \ No newline at end of file From b668bfb4c17b63648cf984e407974af1426448bc Mon Sep 17 00:00:00 2001 From: Ivan Chukhalo Date: Mon, 3 Oct 2022 04:51:18 +0300 Subject: [PATCH 3/3] pre-OOP: fixed typical mistake, applyed DRY principle for printing creature info --- .../ivan-chukhalo/tjw-without-oop/index.js | 103 +++++++++--------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/submissions/ivan-chukhalo/tjw-without-oop/index.js b/submissions/ivan-chukhalo/tjw-without-oop/index.js index 7593efa230..a8b002fd65 100644 --- a/submissions/ivan-chukhalo/tjw-without-oop/index.js +++ b/submissions/ivan-chukhalo/tjw-without-oop/index.js @@ -1,53 +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, - }; - - print(getInfo(janLevinson)); - print(getInfo(michaelScott)); - print(getInfo(theirDog)); - print(getInfo(theirCat)); - \ No newline at end of file + 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)); +});