From 5ef0715fbc747f202d32cbe7d89327cb0a10c846 Mon Sep 17 00:00:00 2001 From: avisilber88 Date: Fri, 10 Nov 2023 14:20:27 -0500 Subject: [PATCH] Update rewritesigfigs.js --- rewritesigfigs.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/rewritesigfigs.js b/rewritesigfigs.js index f668c69e..ed59cd91 100644 --- a/rewritesigfigs.js +++ b/rewritesigfigs.js @@ -2,14 +2,30 @@ $(document).ready(function(){ //beginning of the things to replace var whatnameis = ""// prompt ("What is your name?"); + + +var endSpace=""; + var askagain = function (whatnameis){ whatnameis = prompt ("What is your full name (first and last)?"); + whatnameis=whatnameis.replace(/\s+/g, ' '); + // console.error(whatnameis); + // console.log(whatnameis.slice(0, 1)); + // alert("hello"+whatnameis); + if (whatnameis.slice(0, 1)==' '){ + whatnameis=whatnameis.slice(1); + } + endSpace = whatnameis.slice(-1); if (whatnameis.length<2){ askagain(); } else if (!(/\s/.test(whatnameis))) { // It has any kind of whitespace - askagain() + askagain(); + } + else if(endSpace==" ") { + console.log("ends with space"); + askagain(); } else{ document.getElementById("nameis").innerHTML = whatnameis; @@ -423,4 +439,4 @@ thisAnswer=""+round(thisAnswer, 0); //alert (thisAnswer); alert (" You, "+whatnameis+" got a score of "+score + " on "+ m + " / " + d + " / " + y +" on app " + thisAppNum); }); -}); \ No newline at end of file +});