diff --git a/Activity1.js b/Activity1.js new file mode 100644 index 0000000..1a9fec0 --- /dev/null +++ b/Activity1.js @@ -0,0 +1,18 @@ +let numArray = [1,2,3,4,5]; + +console.log(numArray); + +let reverseArr = [ numArray[4],numArray[3],numArray[2],numArray[1],numArray[0] ]; + +console.log(reverseArr); + +qwEmployee = { + "full_name": "Duran Brooks", + "position": "Consultant I", + "age": 27, + "gender": "male" +} + +let employeeString = `${qwEmployee.full_name} is a ${qwEmployee.age} year old ${qwEmployee.gender} and a QW ${qwEmployee.position}`; + +console.log(employeeString); diff --git a/Activity2.js b/Activity2.js new file mode 100644 index 0000000..deb721c --- /dev/null +++ b/Activity2.js @@ -0,0 +1,19 @@ +const druid = { + 'age': 21, + 'armour': '', + 'killsOnBattleField': 11 +} + +if (druid.age >= 10 && druid.age < 15) { + druid.armour = 'bronze'; +} else if (druid.age >= 15 && druid.age < 20) { + if (druid.killsOnBattleField > 90) { + druid.armour = 'silver maximum'; + } else { + druid.armour = 'silver'; + } +} else if (druid.age >= 20) { + druid.armour = 'titanium'; +} + +console.log(druid); diff --git a/Activity3.js b/Activity3.js new file mode 100644 index 0000000..bdaa109 --- /dev/null +++ b/Activity3.js @@ -0,0 +1,44 @@ +let youngDruid = { + 'age': 10, + 'armour': 'silver', + 'killsOnBattleField': 98 +} + +let archonDruid = { + 'age': 22, + 'armour': 'silver plus', + 'killsOnBattleField': 902 +} + +function updateDruidAge(druid, newAge) { + druid.age = newAge; + return druid; +} + +function checkUpgradeEligibility(druid) { + if (druid.age >= 10 && druid.age < 15 && druid.armour == null) { + return true; + } else if (druid.age >= 15 && druid.age < 20) { + if (druid.killsOnBattleField > 90 && druid.armour != 'silver maximum') { + return true; + } else if (druid.armour != 'silver') { + return true; + } + } else if (druid.age >= 20 && druid.armour != 'titanium') { + return true; + } + + return false; +} + +let eligible = checkUpgradeEligibility(youngDruid); +console.log(eligible); + +eligible = checkUpgradeEligibility(archonDruid); +console.log(eligible); + +youngDruid = updateDruidAge(youngDruid, 13); +console.log(youngDruid); + +archonDruid = updateDruidAge(archonDruid, 26); +console.log(archonDruid); diff --git a/Activity4.js b/Activity4.js new file mode 100644 index 0000000..ee9115f --- /dev/null +++ b/Activity4.js @@ -0,0 +1,44 @@ +let druidArray = [ + { + 'name': 'John', + 'age': 10, + 'armour': 'silver', + 'killsOnBattleField': 98 + }, + + { + 'name': 'Jayson', + 'age': 15, + 'armour': '', + 'killsOnBattleField': 11 + }, + + { + 'name': 'Jerome', + 'age': 21, + 'armour': '', + 'killsOnBattleField': 21 + }, + + { + 'name': 'Jane', + 'age': 32, + 'armour': 'silver plus', + 'killsOnBattleField': 902 + } +] + +function filterLessThanFifteen(druid) { + return result = druid.age < 15 ? true : false; +} + +const filteredList = druidArray.filter(filterLessThanFifteen); +console.log(filteredList); + +function minusAge(druid) { + druid.age -= 1; + return druid; +} + +const moddedDruids = druidArray.map(minusAge); +console.log(moddedDruids); \ No newline at end of file diff --git a/Activity5.js b/Activity5.js new file mode 100644 index 0000000..baef816 --- /dev/null +++ b/Activity5.js @@ -0,0 +1,41 @@ +const druidArray = [ + { + 'name': 'John', + 'age': 10, + 'armour': 'silver', + 'killsOnBattleField': 98 + }, + + { + 'name': 'Jayson', + 'age': 15, + 'armour': '', + 'killsOnBattleField': 11 + }, + + { + 'name': 'Jerome', + 'age': 21, + 'armour': '', + 'killsOnBattleField': 21 + }, + + { + 'name': 'Jane', + 'age': 32, + 'armour': 'silver plus', + 'killsOnBattleField': 902 + } +] + +// NEED TO SORT THE ARRAY LATER + +for (const element of druidArray) { + for (const key in element) { + if (Object.hasOwnProperty.call(element, key)) { + const druid = element[key]; + console.log(`${key}: ${druid}`); + } + } + console.log(''); +} \ No newline at end of file diff --git a/README.md b/README.md index cfdcdbc..10cd39e 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,6 @@ perform the following activities: - commit your new files - push your changes - create a PR to the repository that you forked from (this repository if you have not forked as yet) + +------------------------------------------------------------------------------------------------------------------------------------ +DONE! \ No newline at end of file