At the beginning of this course I always used to get stuck on simple code problems because I was not reading through the material properly or I jumped into the assigments straight away. I remember something on my website did not work properly and I was stuck for almost 3 hours. Stress levels were really high, and I reached the point that I had to go out for a walk to distract my mind. After that I read through my code again and I found out that I did not link the file properly. I learnt that breaks are really important!
Pseudocode: I have not used this technicque yet or properly, I always trying to explain my problem to Mr. Potato Head
Trying something: This is a good technique that I use often.
Rubber ducky method: I use this method often but I am using Mr. Potato Head instead.
Reading error messages: This is very useful too. Also when you are debugging it is amazing how the dev tool shows you exactly where the error is located.
Console.logging: I have not used this method yet, I think I will use it later on debugging websites.
Googling: This is probably the number one on the list, the one I use most often. Google is an amazing problem solving tool.
Asking your peers for help: I ask for help when I am completely stuck. I always like to solve the problem on my own first then ask for help, but definetly this method is really helpfull.
Asking coaches for help: I have not asked for help yet. Probably soon!
Improving your process with reflection: This is good as well, or even taking some time off helps.
Array.prototype.map(): The map() method creates a new array with the results of calling a function for every array element.
Return an array with the square root of all the values in the original array:
var numbers = [4, 9, 16, 25];
function myFunction() {
x = document.getElementById("demo")
x.innerHTML = numbers.map(Math.sqrt);
}
The result will be:
2,3,4,5
Array.prototype.filter(): Creates a new array with all of the elements of this array for which the provided filtering function.
Example:
Return an array of all the values in the ages array that are 18 or over:
var ages = [32, 33, 16, 40];
function checkAdult(age) {
return age >= 18;
}
function myFunction() {
document.getElementById("demo").innerHTML =
ages.filter(checkAdult);
}
The result will be:
32,33,40
Array.prototype.reduce(): The reduce() method reduces the array to a single value, executes a provided function for each value of the array (from left-to-right).
Get the sum of the numbers in the array:
var numbers = [65, 4, 1, 4];
function getSum(total, num) {
return total + num;
}
function myFunction(item) {
document.getElementById("demo").innerHTML =
numbers.reduce(getSum);
}
The total of numbers in Array :74