It gets me so pumped up every time I recieve a notification from your channel. I thoroughly enjoy your tutorials. I'm in love with the way you explain complex stuff. You're so gifted 😍 You definitely have a knack for it.
Im studying computer science right now and the explanation they gave us i think is easier to understand that what youre trying to explain. Impure functions are functions that do more than only what they state in their name f.e. let half = 0; function sum(a, b) { half = (a+b) /2 return a+b; } As you can see, this 'sum' function is making an addition AND calculating/doing something else that has nothing to do with the name of the function 'sum'. To make it pure, you need to split the calculation into seperate functions; such as let half = 0; function sum(a, b) { divideBy2(a, b); return a+b; } function divideBy2(a, b) { half = (a+b)/2; } or even cleaner, but now you also change the structure so this might not be what you want since a and b dont need to be equal for both functions function sum(a, b) { return a + b; } function divideBy2(a, b) { return (a + b) / 2; } let result = sum(4, 6); // 10 let half = divideBy2(4, 6); // 5
It gets me so pumped up every time I recieve a notification from your channel. I thoroughly enjoy your tutorials. I'm in love with the way you explain complex stuff. You're so gifted 😍 You definitely have a knack for it.
Thank you so much! You’re comments are fast becoming amongst my favourites! 😃👍 Are there any other tutorials you’d like to see on the channel?
YES! like Angular, React and Node.js@@DevDreamer
Im studying computer science right now and the explanation they gave us i think is easier to understand that what youre trying to explain.
Impure functions are functions that do more than only what they state in their name f.e.
let half = 0;
function sum(a, b) {
half = (a+b) /2
return a+b;
}
As you can see, this 'sum' function is making an addition AND calculating/doing something else that has nothing to do with the name of the function 'sum'.
To make it pure, you need to split the calculation into seperate functions; such as
let half = 0;
function sum(a, b) {
divideBy2(a, b);
return a+b;
}
function divideBy2(a, b) {
half = (a+b)/2;
}
or even cleaner, but now you also change the structure so this might not be what you want since a and b dont need to be equal for both functions
function sum(a, b) {
return a + b;
}
function divideBy2(a, b) {
return (a + b) / 2;
}
let result = sum(4, 6); // 10
let half = divideBy2(4, 6); // 5
Thank you for making it this clear.A real great video👏
comment for support
Thank you!
Wonderful video sir. Thanks a lot
👍👍👍 cool
Thank you 🙂👍
Very nice 😊
Thanks!
could you create react js step by step tutorials like this? :)