Skip to content

Commit

Permalink
Only run when values are present
Browse files Browse the repository at this point in the history
  • Loading branch information
jiffyclub committed Dec 2, 2021
1 parent 30b95fa commit 098bf35
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions secretsanta.js
Expand Up @@ -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'));
}
}

0 comments on commit 098bf35

Please sign in to comment.