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

This is what I did during the workshop. #4

Open
wants to merge 2 commits into
base: main
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
18 changes: 18 additions & 0 deletions Activity1.js
Original file line number Diff line number Diff line change
@@ -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);
19 changes: 19 additions & 0 deletions Activity2.js
Original file line number Diff line number Diff line change
@@ -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);
44 changes: 44 additions & 0 deletions Activity3.js
Original file line number Diff line number Diff line change
@@ -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);
44 changes: 44 additions & 0 deletions Activity4.js
Original file line number Diff line number Diff line change
@@ -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);
41 changes: 41 additions & 0 deletions Activity5.js
Original file line number Diff line number Diff line change
@@ -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('');
}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!