Skip to content

Commit

Permalink
Use string.trim()
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrose committed Dec 2, 2023
1 parent 2b445b0 commit 3c26d9e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function submitNames() {
var value = document.getElementById('names').value;
var names = value.split(',').map((s) => s.replace(/\s/g, ""));
var names = value.split(',').map((s) => s.trim());
links = document.getElementById("links");

if (names.length <= 1) {
Expand Down
4 changes: 2 additions & 2 deletions who.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ function main() {
var gifter
var giftee
[gifter, giftee] = new TextDecoder().decode(base64ToBytes(document.location.hash.split("#")[1])).split(",")
gifter = gifter.replace(/^\s+/g, '');
giftee = giftee.replace(/^\s+/g, '');
gifter = gifter.trim();
giftee = giftee.trim();
document.getElementById("who").innerHTML = "Hello, " + gifter + "! You are buying a gift for " + giftee + ".";
}

Expand Down

0 comments on commit 3c26d9e

Please sign in to comment.