These are some examples of previously created materials by mentors that you can use yourself, or for inspiration.
> Focus on having lots of in class exercises.
> DONT teach everything, let the students investigate topics on their own aswell!
> Focus on how to read documentation, google answers and google errors!!
> Teach towards the students being able to solve the homework
Remember to add the code you wrote in the class to the relevant class branch's class work folder. If the branch has not been created just create and push it :) If you dont have access, write to one from the core team. You can see an example below!
To find examples of what teachers have taught before go to the class branches in the classwork folder, Fx class 07
If you find anything that could be improved then please create a pull request! We welcome changes, so please get involved if you have any ideas!!!
Start VERY simple. Just a class that has few fields, no methods. Explain the diff from object to class. Explain instance etc. When they get that move on to class methods. Only teach extends if they really are on top of things otherwise just get them comfortable with classes :) if you can repeat a bit of promise, maybe when working with class that would be great.
- Classes
- Constructor
- Instance
- Methods
this
- Refers to the instance of the class. Do go into too much detail and edge cases. Avoid mentioning
bind
,apply
, etc unless you find it super important, the students will just forget it anyway!
- Refers to the instance of the class. Do go into too much detail and edge cases. Avoid mentioning
- Exercise
- Extend (Only if time!)
At this point good coding practices is starting to get very important! Check our coding best practices and use these both when live coding but also in reviews.
class Comment {
constructor(username, content, time) {
this.username = username;
this.content = content;
this.time = time;
}
}
const comment1 = new Comment('test', 'post', new Date());
class Comment {
constructor(username, content, time) {
this.username = username;
this.content = content;
this.time = time;
}
// Get help from students to write this method!
getTimeSincePost() {
return new Date().getTime() - this.time.getTime();
}
// Get help from students to write this method!
hasSwearWord() {
const swearWords = ['crap', 'damn'];
const postWords = this.content.split(' ');
const hasSwearWord = swearWords.find(swearWord => postWords.includes(swearWord));
return Boolean(hasSwearWord);
}
}
const comment1 = new Comment('test', 'post', new Date());
console.log(comment1.hasSwearWord())
comment1.content = 'shit crap'
console.log(comment1.hasSwearWord())
setTimeout(() => {
console.log(comment1.getTimeSincePost())
}, 1000);
// data
// username, content, time
// functionality
// getTimeSincePost, hasSwearWord
class Post {
// setup
constructor(username, content, postTime, likes, comments, shares) {
this.username = username;
this.content = content;
this.postTime = postTime;
this.likes = likes;
this.comments = comments;
this.shares = shares;
}
addLike(username, time) {
const like = {
username: username,
time: time
};
this.likes.push(like);
}
addComment(username, content, time) {
this.comments.push(new Comment(username, content, time));
}
doShare() {
}
save() {
}
logThis() {
console.log(this.username);
}
}
const post1 = new Post('benna100', 'asd', '10/02/1019', [], [], []);
const post2 = new Post('habsdhjd', 'asdajhdb', '10/02/1019', [], [], []);
post1.addLike('bennaasdasd', '14:07');
console.log(post1.likes);
post1.addComment('ugg', 'Great post', '14:16');
console.log(post1.comments);
post1.logThis();
post2.logThis();
The class should have 2 properties: firstName and lastName. Hint: Use this
and constructor
.
Use the new
keyword and assign the instance in a variable.
- Try to log out the instance of the
User
to the console. - Try to log out the users
firstName
The method should be called getFullName
, and should return the combined first name and last name of the user. Use string concatenation or template literals. Remember to use the this
keyword to access the attributes on the class instance.
Call the getFullName
method and log the result to the console.
The CV that we will be making uses three classes: Job
, Education
and
CV
. The CV
class we have made for you (with some missing functionality). The Job
and Education
classes you need to create.
Create the classes Job
and Education
.
Job
has five properties:id
,title
,description
,startDate
andendDate
(the dates can be strings or actualDate
objects).Education
has six properties:id
,title
,school
,address
,startDate
andendDate
.
class Job {
///...
}
class Education {
///...
}
Now add the functionality for the methods in the CV
class.
Remember: jobs and educations are just arrays of class instances. So use your array manipulation knowledge for the add and remove methods.
class CV {
constructor(email) {
this.jobs = [];
this.educations = [];
//this.email = ?
}
addJob(job) {
// add functionality here
}
removeJob(job) {
// add functionality here
}
addEducation(education) {
// add functionality here
}
removeEducation(education) {
// add functionality here
}
}
-
Create a new
CV
instance using thenew
keyword, and save it in a variable calledmyCV
. -
Apply the methods you have created on the
myCV
object. Create a fewJob
andEducation
objects and add them to your CV. -
Remove a job and an education from
myCV
. -
Log
myCV
to the console, again, and check that the objects were removed correctly.
Add a method to the CV
class called renderCV()
. This method should render out the CV using HTML. Use document.getElementById("<id>")
and document.createElement("<element>")
, as well as element.appendChild(<element>)
to build your HTML using JavaScript.
Thank you very much for teaching Javascript 3, we hope you enjoyed it ! Now it is your time to give feedback about the module. For homework helpers, please click here to give us feedback. For teachers, your survey is available here.