Edit in JSFiddle

function pauseGame() {
    // Insert here the logic to pause your game
    if (window.console && window.console.log) {
        console.log('The advertisement is about to show, you should pause your game');
    }
}

function resumeGame(data) {

		// Check if the reward should be granted
    if (data && data.completed) {
    		// the player can be granted a reward
    }
    
    // Insert here the logic to resume your game
    if (window.console && window.console.log) {
        console.log('The advertisment is shown and your game can now be resumed');
    }
}