From 098bf35004cec057f6cdb25a3b6d688c6ebbe4ab Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Thu, 2 Dec 2021 10:51:02 -0800 Subject: [PATCH] Only run when values are present --- secretsanta.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/secretsanta.js b/secretsanta.js index 9902286..20fdf1b 100644 --- a/secretsanta.js +++ b/secretsanta.js @@ -63,11 +63,14 @@ async function type_text(str, element) { async function run_decode() { const key_value = document.getElementById('santa-key').value; const name_value = document.getElementById('santa-name').value; - const name = decode(key_value, name_value); - await type_text( - `Your Secret Santa recipient is: ${name}`, - document.getElementById('santa-output') - ); - await type_text('Keep it secret', document.getElementById('secret-output')); - await type_text('Keep it safe', document.getElementById('safe-output')); + + if (!!key_value && !!name_value) { + const name = decode(key_value, name_value); + await type_text( + `Your Secret Santa recipient is: ${name}`, + document.getElementById('santa-output') + ); + await type_text('Keep it secret', document.getElementById('secret-output')); + await type_text('Keep it safe', document.getElementById('safe-output')); + } }