Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kenny Submission #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
added triangle function
  • Loading branch information
kach92 committed Jul 1, 2019
commit 7ecd5f7964df6017df788b55d640f611ece0512d
17 changes: 16 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var inputHappened = function(currentInput){
if(!emojiEntered){
emojiEntered = true;
emoji = currentInput;
document.querySelector(".message").innerText = `The emoji you entered is ${emoji}.\nEnter a number or multiple numbers to display them. Use 'clear' to clear rows`;
document.querySelector(".message").innerText = `The emoji you entered is ${emoji}.\nEnter a number or multiple numbers to display them. Use 'clear' to clear rows. (try triangle followed by a number)`;
}else{
//handles input that has spaces
if(currentInput.includes(" ")){
Expand All @@ -24,6 +24,16 @@ var inputHappened = function(currentInput){
displayError();
}
}
//handles triangle
else if(arr[0]=== "triangle"){
if(!isNaN(parseInt(arr[1]))){
makeTriangle(parseInt(arr[1]));
displayError(" ");
}
else{
displayError();
}
}
//if first word is a number
else if(!isNaN(parseInt(arr[0]))){
display(parseInt(arr[0]));
Expand Down Expand Up @@ -81,3 +91,8 @@ var displayError = function (data="Please enter a valid input..") {
error.innerText = data;
}

var makeTriangle = function(num){
for(i=1;i<num+1;i++){
display(i);
}
}