I am new to problem-solving. I found a code for finding the nth Fibonacci number. But I am confused about the work of some variables.
var fibonacci = function (n) {
let prev = 0,
cur = 1,
temp;
for (let i = 1; i < n; i++) {
temp = cur;
cur = cur + prev;
prev = temp;
}
return cur;
};
can you describe what the temp cur and prev variable is doing? especially the temp variable.
Thank you!