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

6m-software-entry-test_addedMyInputs #6

Open
wants to merge 1 commit 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
56 changes: 56 additions & 0 deletions 6m-software-entry-test-main/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Software Developer Professional (6 Months) Entry Assessment

## Brief

In this assessment, you will be given references for self study before making an attempt to five coding practices. To download this folder, you can clone it or download this as a zip file.

![Screenshot](/assets/screenshot-code.png)

Click on the green button with `Code` and choose `Download ZIP`. The entire assessment should not take you more than **2 hours**.

## Expected Audience

- Individuals with an IT background to diversify/expand their skills and/or intending to switch to a software developer role.
- Those with IT or Engineering degree/diploma, or
- Those with IT or Engineering experience professionally
- Full-time professionals seek to upskill within the tech industry. (E.g. System Admin to be Software Developer)


## References

These references should take you not more than 30 minutes to complete.

Reference with code practice:

- [Variables](https://www.w3schools.com/js/js_variables.asp) (1 minute)
- [Data Types](https://www.w3schools.com/js/js_datatypes.asp) (1 minute)
- [Operators](https://www.w3schools.com/js/js_operators.asp) (3 minutes)
- [Conditions](https://www.w3schools.com/js/js_if_else.asp) (3 minutes)
- [Arrays](https://www.w3schools.com/js/js_arrays.asp) (5 minutes)
- [For Loop](https://www.w3schools.com/js/js_loop_for.asp) (5 minutes)
- [Objects](https://www.w3schools.com/js/js_objects.asp) (5 minutes)
- [Classes](https://www.w3schools.com/js/js_classes.asp) (5 minutes)
- [NodeJS Modules](https://www.w3schools.com/nodejs/nodejs_modules.asp) (5 minutes)

These videos can be helpful in learning JavaScript

- [JavaScript with Mosh](https://youtu.be/W6NZfCO5SIk)
- [JavaScript - Travesty Media](https://www.youtube.com/watch?v=hdI2bqOjy3c)


## Problems

Please attempt the solve the problems described in the following `.js` file:

- [Question 1](./src/q1.js)
- [Question 2](./src/q2.js)
- [Question 3](./src/q3.js)
- [Question 4](./src/q4.js)
- [Question 5](./src/q5.js)

## Submission

- You could submit by zipping up the project folder, place it on a public google drive, and submit the URL to NTU Survey Portal, or
- Submit a github url if you have knowledge of using github.

> Should you face any difficulties, please contact your program administrator.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions 6m-software-entry-test-main/src/external.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//Do not change anything in this file. Only q5.js is the one that needs to be changed.
const print = () => {
return "Hello World";
}

export default print;

30 changes: 30 additions & 0 deletions 6m-software-entry-test-main/src/q1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Task 1
- Create a function that would swap the value of x and y using only x and y as variables.
- x and y must be numeric.
- return -1 if x and y is not numeric.
- print the swapped values in the console

Task 2
- invoke the function "swap"
*/

// Task 1: Add code here

function swap(x, y){

if(typeof x != 'number' || typeof y != 'number')
return -1;
else {
[x,y]=[y,x]; //use of destructing assignment
console.log(`x is: ${x}, y is ${y}`);
}
}

// Task 2: Add code here

swap(11,223);
swap('1',2);
swap(234,'12');

module.exports = swap();
33 changes: 33 additions & 0 deletions 6m-software-entry-test-main/src/q2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Task 1:
- Declare an array that are going to be used to store patient's name.

Task 2:
- Add code to add patient's name into the array declared in task 1.

Task 3:
- Implement listPatient() function to print all patient's name stored in the array
*/


// Task 1: Add code here
let patientNames = [];


function addPatient(patientName){

// Task 2: Add code here
patientNames.push(patientName);
}

// Task 3: Add code here

addPatient("John");
addPatient("Mary");
addPatient("Mark");

function listPatient() {
console.log(patientNames);
}

listPatient(); // This should list ["John", "Mary", "Mark"]
19 changes: 19 additions & 0 deletions 6m-software-entry-test-main/src/q3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Task 1:
- Add a new property "breed" with the value "Poodle"

Task 2:
- Implement a for-in to loop through the keys in "dog" object and print it with console.log()
*/

const dog = {
petName: "Bobby"
};

// Task 1: Add code here
dog.breed = "Poodle";

// Task 2: Add code here
for (const key in dog) { // can also use Object.keys(dog); method if your browser is compatible
console.log(key);
}
42 changes: 42 additions & 0 deletions 6m-software-entry-test-main/src/q4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Task 1:
- Implement a Child class that extends the Parent.
- Add a constructor to the Child class can calls super().
- Implement a new function addNewAbilities(newAbility) in the Child class where the new ability will be added to the Parent's #abilities array.
*/
class Parent{
abilities = []

constructor(){
this.abilities.push("Parenting");
this.abilities.push("Role modeling");
}

showAbilities(){
console.log("These are the abilities:")
for(const a of this.abilities){
console.log(a);
}
}
}


const p = new Parent();
p.showAbilities(); // Observe that this function prints "Parenting" and "Role modeling".


// Task 1: Add code here
class Child extends Parent { //extends basically means inheritance
constructor(){
super(); //super() means inherit the parent's constructor
}

addNewAbility(newAbility){ // The default function name is addNewAbility instead of addNewAbilities, thus I shall follow
this.abilities.push(newAbility);
}
}


const c = new Child();
c.addNewAbility("Dancing");
c.showAbilities(); // This function should print "Parenting", "Role modeling" and "Dancing".
10 changes: 10 additions & 0 deletions 6m-software-entry-test-main/src/q5-output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<html>
<head>
<title>Question 5</title>
</head>
<body>
<!--please do not change anything in this file -->
<h1 id="test"></h1>
<script type="module" src="q5.js"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions 6m-software-entry-test-main/src/q5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

/*
Task 1:
- Link the file `external.js` to this file.
- To test if the linking works, open q5-output.html in the browser and it should show "Hello World!"
*/

// Task 1: Add code here
import randomName from "./external.js"; //reference: https://www.scaler.com/topics/javascript/import-js-file-in-js/
const print = randomName;

// Do not change the code below
document.querySelector("#test").innerHTML = print();