Tech Refresh - TimvanAlphen/functional-programming GitHub Wiki
I'm a Javascript beginner. I dind't follow Block Tech last year so i'm doing a JS and GitHub refresh.
So far i have been refreshing these topics:
Week 1 (19-10-2020)
- Basics of Javascript with the FreeCodeCamp course https://www.freecodecamp.org/learn
- Github, the commit, push, pull functions. So i have a record of my work on GitHub. (I'm using GitHub Desktop to push my work. I haven't started using the terminal yet)
- Working with functions in JS. I have been coding with the live coding session that Laurens did on Wednesday 21-10. So far i wrote a function that pushes the survey data to a variable so i can pick out a single column from the dataset.
- Using the filter function. I have been using a video to learn about filter (https://www.youtube.com/watch?v=BMUiFMZr7vk&ab_channel=FunFunFunction). Using this video i worte simple code so i can pick out MBO, HAVO or VWO out of the "vooropleiding" Column.
- Using the map function. I used a different video by the same creator to learn about the map function (https://www.youtube.com/watch?v=bCqtb-Z5YGQ&t=300s&ab_channel=FunFunFunction). Using this video i wrote simple code that adds an emoji after MBO, HAVO or VWO.
Using filter and map:
A function that pushes the answers for the survey to an array wich is saved to a variable.
//The survey data is loaded from an .js file.
const surveyAnswers = data
//Variables with the surveyAnwsers and collumnname of "schoenmaat"
let kolomNaam = "vooropleiding"
let lijstAntwoorden = getAnswersForQuestion(surveyAnswers, kolomNaam)
//console.log van de lijst met antwoorden.
console.log("Survey answers are:",lijstAntwoorden)
//Function that saves an array with the answersForQuestions and pushes them to the variable "lijstAntwoorden".
function getAnswersForQuestion(answers, question){
let answersForQuestion = []
for (answer of answers){
answersForQuestion.push(answer[question])
}
return answersForQuestion
}
A filter that goes trough the "lijstAntwoorden" varable and returns only 'Havo'
//The filter function only returns 'MBO' Bron: https://www.youtube.com/watch?v=BMUiFMZr7vk&ab_channel=FunFunFunction
let niveau = lijstAntwoorden.filter(function(lijstAntwoorden) {
return lijstAntwoorden === 'HAVO'
})
A map that adds an emoji "=)" after MBO, HAVO or VWO.
//Map adds an eomji "=)" after MBO.
let emoji = niveau.map(function(niveau){
return niveau + ' =)'
})
console.log("Niveau is:" ,niveau)
console.log(emoji)