From ecac6dc661139641d4dd39764c83a9ccb9ad4a7a Mon Sep 17 00:00:00 2001 From: pasti Date: Mon, 15 Jun 2020 22:38:38 +0800 Subject: [PATCH] version 1 --- index.html | 1 + script.js | 35 ++++++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 77832ae..c6dc61f 100644 --- a/index.html +++ b/index.html @@ -17,3 +17,4 @@

output:

+ diff --git a/script.js b/script.js index 6582e0d..b6f0861 100644 --- a/script.js +++ b/script.js @@ -1,11 +1,32 @@ -console.log("hello script js"); - var inputHappened = function(currentInput){ - console.log( currentInput ); - display( "WOW SOMETHING HAPPENED" ); -}; + display(checkInputisNaN(currentInput)); + if (currentInput == "clear") { + document.querySelector("#output").innerHTML = ""; + } + // } else if(currentInput == "clear 2") { + // currentInput.split[1] + // var selectAllRows = document.querySelectorAll("#output p"); + // selectAllRows[selectAllRows.length - 1].remove(); + // } + }; var display = function(stuffToDisplay){ - // your DOM manipulation code here - + var rowPTag = document.createElement('p'); + rowPTag.textContent = columnPineapple(stuffToDisplay); + document.querySelector("#output").appendChild(rowPTag); +}; + + +var checkInputisNaN = function(input) { + if (isNaN(input)) { + return ; + } else { + num = parseInt(input); + return num; + } +}; + +var columnPineapple = function(num){ + var pineapples = "🍍"; + return pineapples.repeat(num); };