When code doesn't work, add console.log() statements to see what's happening:
function double(x) {
console.log("Input:", x)
let result = x * 2
console.log("Result:", result)
return result
}
Log inputs, outputs, and intermediate values. This shows you where the actual values differ from what you expected. Once you find the bug, remove or comment out the debug statements.