Skip to content

Commit

Permalink
Started work on issue #7
Browse files Browse the repository at this point in the history
  • Loading branch information
EphraimB committed Nov 29, 2015
1 parent ea5f460 commit bcf959b
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,44 @@ submitButton.onclick = function()

var titleValue = title.childNodes[0];

personOneTalk.innerHTML = "Have you heard that " + titleValue.nodeValue + "?";
var topicStarter = titleValue.nodeValue.toLowerCase();

function topicKeywordInFullSentance(keyword)
{
return topicStarter.split(" ").some(function(findTheKeyword)
{
return findTheKeyword == keyword;
});

};

function topicKeyCharacterInFullSentance(keyCharacter)
{
return topicStarter.split("").some(function(findTheKeyCharacter)
{
return findTheKeyCharacter == keyCharacter;
});

};

if(topicKeyCharacterInFullSentance("?"))
{
titleValue.deleteData(topicStarter.length - 1, 1);
}

if(topicKeywordInFullSentance("and"))
{
var start = topicStarter.search("and");

titleValue.deleteData(start - 1, topicStarter.length - start);
}

if(topicKeywordInFullSentance("what") && topicKeywordInFullSentance("is"))
{
titleValue.deleteData(0, 7);
}

personOneTalk.innerHTML = "Have you heard about " + titleValue.nodeValue + "?";

submitButtonFour.onclick = function()
{
Expand Down

0 comments on commit bcf959b

Please sign in to comment.