#869. My own block: add up
When the green flag is clicked, the script on the left runs. What is the value of the **total** variable at the end?
define add up (a) (b) change [total v] by ((a) + (b)) when green flag clicked set [total v] to (0) add up (8) (18) add up (17) (13) add up (12) (1)
def add_up(a, b): # define add up
global total
total += a + b
# When the green flag is clicked
total = 0
add_up(8, 18)
add_up(17, 13)
add_up(12, 1)
let total = 0;
// define add up
function add_up(a, b) {
total += a + b;
}
// When the green flag is clicked
total = 0;
add_up(8, 18);
add_up(17, 13);
add_up(12, 1);
💡 Not sure? Build it in Scratch and try it out.