<body>
    <div id="wrapper"><nav>
      <ul>
        <li><a href=#aboutPA>About</a</li>
        <li><a href=#contact>Contact</a></li>
      </ul>
        </nav></div>
        <h4 id="title">positive affirmation generator</h4>
<div id="affirmation-div">
  <h1 id="affirmation" class="monospace">The past has no power over me anymore.</h1>
  <button id="change-affirmation-button">Click to change affirmation!<br> (or press enter)</button>
</div>
<br><br>
<div id="pronoun-selection">
<h5>Please select your pronouns.</h5>
<input type="radio" name="pronoun-radio" value="I" id="i-box" checked="checked">I</input>
<input type="radio" name="pronoun-radio" value="You" id="you-box">You</input>
<input type="radio" name="pronoun-radio" value="She" id="she-box">She</input>
<input type="radio" name="pronoun-radio" value="They" id="they-box">They</input>
<input type="radio" name="pronoun-radio" value="He" id="he-box">He</input>
</div>
<div id="font-selection">
<h5>... and select a font.</h5>
<input type="radio" name="font-select" value="monospace"><font style="font-family:monospace">Monospace</font></input>
<input type="radio" name="font-select" value="indieflower"><font style="font-family:'Indie Flower', cursive">Indie Flower</font></input>
<input type="radio" name="font-select" value="bungieinline"><font style="font-family:'Bungee Inline', cursive">Bungie Inline</font></input>
<input type="radio" name="font-select" value="lobster"><font style="font-family:'Lobster', cursive">Lobster</font></input>
<input type="radio" name="font-select" value="amita"><font style="font-family:'Amita', cursive">Amita</font></input>
<input type="radio" name="font-select" value="randomise" checked="checked">Randomise</input>
</div>
<div id="aboutPA">
  <h4>About this site.</h4>
  <p>The positive affirmation generator was created at the behest of a friend.
  After searching for positive affirmations online I realised how people may
  respond more positively to different forms of address in an affirmation and
  adjusted the site to reflect different pronouns, including the first and second
  person. I hope you find this site useful, please contact me if you notice any bugs.
  <br>The affirmations used here are originally from <a href="http://www.prolificliving.com/100-positive-affirmations/" target="_blank">this</a> site.
  Not all affirmations have been included in the generator.</p>
</div>
<div id="contact">
  <h4>Contacting the creator.</h4>
  <p>I can be contacted most easily on <a href="https://twitter.com/eleanombre" target="_blank">twitter</a>! You can also look at my
    <a href="https://codepen.io/eleanombre/full/oLZOXZ/" target="_blank">portfolio</a> for more information on how to reach me.</p>
</div>
<footer>
  <p><a href="https://github.com/eleanombre">&copy; 2016 Eleanor Keane.</a></p>
</footer>
<script src="scripts.js" type="text/javascript"></script>
</body>
/*************
colours:

key =  "han blue" #44A3FF

triad :

pale green = #A3FF44
han blue = #44A3FF
dark teal = #197BD9 ( lighter; #90C9FF )

intense pale green  = #A3FF44
dark pastel green = #7BD919
more yellow pale green = #B6FF6A

**************/


h1 {
  color: #004566;
}

h4 {
 color: #44A3FF;
}

body {
  background-color: #FFF; /* blue grey */
  font-family: 'Open sans', sans-serif;
}

a {
  color: #2F71B2;
}
a:visited {
  color: #5A9AD9;
}

#title {
  border-color: #004566;
  border-bottom: dashed 2px;
}

#title h4 {
  color: #90C8FF;
}

#affirmation-div {
  max-width: 100%;
  display: block;
  margin-left: 15%;
  margin-right: 15%;
  margin-top: 70px;
}

button {
  border-radius: 14%;
  font-family: monospace;
}

#pronoun-selection {
  max-width: 100%;
  display: block;
  margin-left: 15%;
  margin-right: 15%;
}

#pronoun-selection input[type='radio'] {
  margin: 2.5%;
}

#font-selection {
  max-width: 100%;
  display: inline-block;
  margin-left: 15%;
  margin-right: 15%;
}

#font-selection input[type='radio'] {
  margin: 5%;
}

#aboutPA {
  text-align: justify;
  margin-top: 105px;
  max-width: 100%;
  display: block;
  margin-left: 15%;
  margin-right: 15%;
}

#contact {
  text-align: justify;
  margin-top: 10px;
  max-width: 100%;
  display: block;
  margin-left: 15%;
  margin-right: 15%;
}

footer {
  text-align: center;
  max-width: 100%;
  display: block;
  margin-left: 15%;
  margin-right: 15%;
}

footer a {
    color: #90C8FF;
}
footer a:visited {
    color: #90C8FF;
}

/***********
navigation
************/
#wrapper {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
}
nav {
  text-align: right;
  padding: 4px 0;
  margin-top: 0px 0 0;
}

nav ul {
  list-style: none;
  margin: 0 5px;
  padding: 0;
}

nav li {
  display: inline-block;
}

nav a {
  font-weight: 800;
  padding: 15px 10px;
}

/*** font classes ***/

.monospace {
  font-family: Monospace, sans-serif;
}

.indieflower {
  font-family:'Indie Flower', cursive;
}

.bungieinline {
  font-family: 'Bungee Inline', cursive;
}

.amita {
  font-family:'Amita', cursive;
}

.lobster {
  font-family: 'Lobster', cursive;
}
/*array for I, you, they pronouns*/
/* ISSUE!!!! was vs were in you / they / I  */
var arrPositiveYou1 = ["Pronoun1 feel the love of those who are not physically around pronoun15", "Pronoun1 take pleasure in pronoun2 own solitude", "Pronoun4 too big a gift to this world to feel self-pity", "Pronoun1 love and approve of pronoun3", "Pronoun1 focus on breathing and grounding pronoun3", "Following pronoun2 intuition and pronoun2 heart keeps pronoun15 safe and sound", "Pronoun1 make the right choices every time", "Pronoun1 draw from pronoun2 inner strength and light", "Pronoun1 trust pronoun3", "Pronoun4 a unique child of this world", "Pronoun1 have as much brightness to offer the world as the next person", "Pronoun1 matter and what Pronoun1 have to offer this world also matters", "Pronoun1 trust pronoun2 inner wisdom and intuition", "Pronoun1 breathe in calmness and breathe out nervousness", "This situation works out for pronoun2 highest good", "Wonderful things unfold before pronoun15", "Pronoun1 forgive pronoun3 for all the mistakes Pronoun1 have made", "Pronoun1 let go of pronoun2 anger so Pronoun1 can see clearly", "Pronoun1 accept responsibility if pronoun2 anger has hurt anyone", "Pronoun1 replace pronoun2 anger with understanding and compassion", "Pronoun1 offer an apology to those affected by pronoun2 anger", "Pronoun1 may not understand the good in this situation but it is there", "Pronoun1 muster up more hope and courage from deep inside pronoun15", "Pronoun1 choose to find hopeful and optimistic ways to look at this", "Pronoun1 kindly ask for help and guidance if Pronoun1 cannot see a better way", "Pronoun1 refuse to give up because Pronoun1 haven't tried all possible ways", "Pronoun1 know pronoun2 wisdom guides pronoun15 to the right decision", "Pronoun1 trust pronoun3 to make the best decision for pronoun15", "Pronoun1 receive all feedback with kindness but make the final call pronoun3", "Pronoun1 listen lovingly to this inner conflict and reflect on it until Pronoun1 get to peace around it", "Pronoun1 love pronoun2 family even if they do not understand pronoun15 completely", "Pronoun1 show pronoun2 family how much Pronoun1 love them in all the verbal and non-verbal ways Pronoun1 can", "There is a good reason Pronoun1 was paired with this perfect family", "Pronoun1 choose to see pronoun2 family as a gift", "Pronoun4 a better person from the hardship that I've gone through with pronoun2 family", "Pronoun1 choose friends who approve of pronoun15 and love pronoun15", "Pronoun1 surround pronoun3 with people who treat pronoun15 well", "Pronoun1 take the time to show pronoun2 friends that Pronoun1 care about them", "Pronoun2 friends do not judge pronoun15, nor do they influence what Pronoun1 do with pronoun2 life", "Pronoun1 take great pleasure in pronoun2 friends, even if they disagree or live different lives", "Pronoun4 beautiful and smart and that's how everyone sees pronoun15", "Pronoun1 take comfort in the fact that Pronoun1 can always leave this situation", "Pronoun1 never know what amazing incredible person Pronoun1 will meet next", "The company of strangers teaches pronoun15 more about pronoun2 own likes and dislikes", "Pronoun4 doing work that Pronoun1 enjoy and find fulfilling", "Pronoun1 play a big role in pronoun2 own career success", "Pronoun1 ask for and do meaningful, wonderful and rewarding work", "Pronoun1 engage in work that impacts this world positively", "Pronoun1 believe in pronoun2 ability to change the world with the work that Pronoun1 do", "Peaceful sleep awaits pronoun15 in dreamland", "Pronoun1 let go of all the false stories Pronoun1 make up in pronoun2 head", "Pronoun1 release pronoun2 mind of thought until the morning", "Pronoun1 embrace the peace and quiet of the night", "Pronoun1 sleep soundly and deeply and beautifully into this night", "This day brings pronoun15 nothing but joy", "Today will be a gorgeous day to remember", "Pronoun2 thoughts are pronoun2 reality so Pronoun1 think up a bright new day", "Pronoun1 fill pronoun2 day with hope and face it with joy", "Pronoun1 choose to fully participate in pronoun2 day", "Pronoun1 let go of worries that drain pronoun2 energy", "Pronoun1 make smart, calculated plans for pronoun2 future", "Pronoun4 a money magnet and attract wealth and abundance", "Pronoun4 in complete charge of planning for pronoun2 future", "Pronoun1 trust in pronoun2 own ability to provide well for pronoun2 family", "Pronoun1 follow pronoun2 dreams no matter what", "Pronoun1 show compassion in helping pronoun2 loved ones understand pronoun2 dreams", "Pronoun1 ask pronoun2 loved ones to support pronoun2 dreams", "Pronoun1 answer questions about pronoun2 dreams without getting defensive", "Pronoun2 loved ones love pronoun15 even without fully grappling with pronoun2 dreams", "Pronoun1 accept everyone as they are and continue on with pursuing pronoun2 dream", "Pronoun4 safe and sound. All is well", "Everything works out for pronoun2 highest good", "There is a great reason this is unfolding before pronoun15 now", "Pronoun1 have the smarts and the ability to get through this", "All pronoun2 problems have a solution", "Pronoun1 attempt all - not some - possible ways to get unstuck", "Pronoun1 seek a new way of thinking about this situation", "The answer is right before pronoun15, even if Pronoun4 not seeing it yet", "Pronoun1 believe in pronoun2 ability to unlock the way and set pronoun3 free", "Pronoun1 have no right to compare pronoun3 to anyone for Pronoun1 do not know their whole story", "Pronoun1 compare pronoun3 only to pronoun2 highest self", "Pronoun1 choose to see the light that Pronoun4 to this world", "Pronoun4 happy in pronoun2 own skin and in pronoun2 own circumstances", "Pronoun1 see pronoun3 as a gift to pronoun2 people and community and world", "Pronoun4 more than good enough and Pronoun1 get better every day", "Pronoun1 give up the habit of criticising pronoun3", "Pronoun1 adopt the mindset of praising pronoun3", "Pronoun1 see the perfection in all pronoun2 flaws and all pronoun2 genius", "Pronoun1 fully approve of who Pronoun4, even as Pronoun1 get better", "Pronoun4 a good person at all times of day and night", "Pronoun1 cannot give up until Pronoun1 have tried every conceivable way", "Giving up is easy and always an option so let's delay it for another day", "Pronoun1 press on because Pronoun1 believe in pronoun2 path", "It is always too early to give up on pronoun2 goals", "Pronoun1 must know what awaits pronoun15 at the end of this rope so Pronoun1 do not give up", "The past has no power over pronoun15 anymore. Pronoun1 embrace the rhythm and the flowing of pronoun2 own heart", "All that Pronoun1 need comes to pronoun15 at the right time and place in this life", "Pronoun4 deeply fulfilled with who Pronoun4."];
/* array for she, he pronouns*/
var arrPositiveShe1 = ["Pronoun1 feels the love of those who are not physically around pronoun15", "Pronoun1 takes pleasure in pronoun2 own solitude", "Pronoun1 is too big a gift to this world to feel self-pity", "Pronoun1 loves and approves of pronoun3", "Pronoun1 focuses on breathing and grounding pronoun3", "Following pronoun2 intuition and pronoun2 heart keeps pronoun15 safe and sound", "Pronoun1 makes the right choices every time", "Pronoun1 draws from pronoun2 inner strength and light", "Pronoun1 trusts pronoun3", "Pronoun1 is a unique child of this world", "Pronoun1 has as much brightness to offer the world as the next person", "Pronoun1 matters and what Pronoun1 has to offer this world also matters", "Pronoun1 trusts pronoun2 inner wisdom and intuition", "Pronoun1 breathes in calmness and breathes out nervousness", "This situation works out for pronoun2 highest good", "Wonderful things unfold before pronoun15", "Pronoun1 forgives pronoun3 for all the mistakes Pronoun1 has made", "Pronoun1 lets go of pronoun2 anger so Pronoun1 can see clearly", "Pronoun1 accepts responsibility if pronoun2 anger has hurt anyone", "Pronoun1 replaces pronoun2 anger with understanding and compassion", "Pronoun1 offers an apology to those affected by pronoun2 anger", "Pronoun1 may not understand the good in this situation but it is there", "Pronoun1 musters up more hope and courage from deep inside pronoun15", "Pronoun1 chooses to find hopeful and optimistic ways to look at this", "Pronoun1 kindly asks for help and guidance if Pronoun1 cannot see a better way", "Pronoun1 refuses to give up because Pronoun1 hasn't tried all possible ways", "Pronoun1 knows pronoun2 wisdom guides pronoun15 to the right decision", "Pronoun1 trusts pronoun3 to make the best decisions for pronoun15", "Pronoun1 receives all feedback with kindness but makes the final call pronoun3", "Pronoun1 listens lovingly to this inner conflict and reflects on it until Pronoun1 get to peace around it", "Pronoun1 loves pronoun2 family even if they do not understand pronoun15 completely", "Pronoun1 shows pronoun2 family how much Pronoun1 loves them in all the verbal and non-verbal ways Pronoun1 can", "There is a good reason Pronoun1 was paired with this perfect family", "Pronoun1 chooses to see pronoun2 family as a gift", "Pronoun1 is a better person from the hardship that Pronoun1 gone through with pronoun2 family", "Pronoun1 chooses friends who approve of pronoun15 and love pronoun15", "Pronoun1 surrounds pronoun3 with people who treat pronoun15 well", "Pronoun1 takes the time to show pronoun2 friends that Pronoun1 cares about them", "Pronoun2 friends do not judge pronoun15, nor do they influence what Pronoun1 does with pronoun2 life", "Pronoun1 takes great pleasure in pronoun2 friends, even if they disagree or live different lives", "Pronoun1 is beautiful and smart and that's how everyone sees pronoun15", "Pronoun1 takes comfort in the fact that Pronoun1 can always leave this situation", "Pronoun1 never knows what amazing incredible person Pronoun1 will meet next", "The company of strangers teaches pronoun15 more about pronoun2 own likes and dislikes", "Pronoun1 is doing work that Pronoun1 enjoys and finds fulfilling", "Pronoun1 plays a big role in pronoun2 own career success", "Pronoun1 asks for and does meaningful, wonderful and rewarding work", "Pronoun1 engages in work that impacts this world positively", "Pronoun1 believes in pronoun2 ability to change the world with the work that Pronoun1 does", "Peaceful sleep awaits pronoun15 in dreamland", "Pronoun1 lets go of all the false stories Pronoun1 makes up in pronoun2 head", "Pronoun1 releases pronoun2 mind of thought until the morning", "Pronoun1 embraces the peace and quiet of the night", "Pronoun1 sleeps soundly and deeply and beautifully into this night", "This day brings pronoun15 nothing but joy", "Today will be a gorgeous day to remember", "Pronoun2 thoughts are pronoun2 reality so Pronoun1 thinks up a bright new day", "Pronoun1 fills pronoun2 day with hope and faces it with joy", "Pronoun1 chooses to fully participate in pronoun2 day", "Pronoun1 lets go of worries that drain pronoun2 energy", "Pronoun1 makes smart, calculated plans for pronoun2 future", "Pronoun1 is a money magnet and attract wealth and abundance", "Pronoun1 is in complete charge of planning for pronoun2 future", "Pronoun1 trusts in pronoun2 own ability to provide well for pronoun2 family", "Pronoun1 follows pronoun2 dreams no matter what", "Pronoun1 shows compassion in helping pronoun2 loved ones understand pronoun2 dreams", "Pronoun1 asks pronoun2 loved ones to support pronoun2 dreams", "Pronoun1 answer questions about pronoun2 dreams without getting defensive", "Pronoun2 loved ones love pronoun15 even without fully grappling with pronoun2 dreams", "Pronoun1 accepts everyone as they are and continue on with pursuing pronoun2 dream", "Pronoun1 is safe and sound. All is well", "Everything works out for pronoun2 highest good", "There is a great reason this is unfolding before pronoun15 now", "Pronoun1 has the smarts and the ability to get through this", "All pronoun2 problems have a solution", "Pronoun1 attempts all - not some - possible ways to get unstuck", "Pronoun1 seeks a new way of thinking about this situation", "The answer is right before pronoun15, even if Pronoun1 is not seeing it yet", "Pronoun1 believes in pronoun2 ability to unlock the way and set pronoun3 free", "Pronoun1 has no right to compare pronoun3 to anyone for Pronoun1 does not know their whole story", "Pronoun1 compares pronoun3 only to pronoun2 highest self", "Pronoun1 chooses to see the light that Pronoun4 to this world", "Pronoun1 is happy in pronoun2 own skin and in pronoun2 own circumstances", "Pronoun1 sees pronoun3 as a gift to pronoun2 people and community and world", "Pronoun1 is more than good enough and Pronoun1 gets better every day", "Pronoun1 gives up the habit of criticising pronoun3", "Pronoun1 adopts the mindset of praising pronoun3", "Pronoun1 sees the perfection in all pronoun2 flaws and all pronoun2 genius", "Pronoun1 fully approves of who Pronoun4, even as Pronoun1 gets better", "Pronoun1 is a good person at all times of day and night", "Pronoun1 cannot give up until Pronoun1 has tried every conceivable way", "Giving up is easy and always an option so let's delay it for another day", "Pronoun1 presses on because Pronoun1 believes in pronoun2 path", "It is always too early to give up on pronoun2 goals", "Pronoun1 must know what awaits pronoun15 at the end of this rope so Pronoun1 does not give up", "The past has no power over pronoun15 anymore. Pronoun1 embraces the rhythm and the flowing of pronoun2 own heart", "All that Pronoun1 needs comes to pronoun15 at the right time and place in this life", "Pronoun1 is deeply fulfilled with who Pronoun1 is." ];
var affirmationText = document.getElementById('affirmation');
var changeAffButton = document.getElementById('change-affirmation-button');
var addNameButton = document.getElementById('add-name-button');
var name = "";
var defaultFont = "randomise";
var numNum = 0;
/* radio buttons */
var radios = document.getElementsByName('pronoun-radio');
var i = radios.length;
while ( --i > -1 ) {
  radios[i].addEventListener("click", returnPronoun);
}
/* font radios */
var fontRadios = document.getElementsByName('font-select');
var j = fontRadios.length;
while ( --j > -1 ) {
  console.log(fontRadios[j].value);
  fontRadios[j].addEventListener("click", changeFont);
}
/* var affirmationPronoun = "I"; */
/* replacement variables */
var replaceShe = ["her", "she", "her", "herself", "she is"];
var replaceThey = ["them", "they", "their", "themself", "they are"];
var replaceHe = [ "him", "he", "his", "himself", "he is"];
var replaceYou = [ "you", "you", "your", "yourself", "you are"];
var replaceI = ["me", "i ", "my", "myself", "i am"];
var replacements = [/pronoun15/ig ,/pronoun1/ig, /pronoun2/ig, /pronoun3/ig, /pronoun4/ig];
var arrayIndex = Math.floor( Math.random() * arrPositiveYou1.length );
var selectedPronoun = "I";/*
- retrieve value of radio button when changing affirmation
- depending on the value call a function
- each function will be pronoun specific (using .replace etc.)

/*
functions required :
*/
function returnPronoun() {
  selectedPronoun = this.value;
  changeAffirmation();
}
/*
- *checkPronoun*
- *changePronoun*
-*pass changed array to -> affirmationSelector*
*/
console.log(selectedPronoun);


function changeAffirmation() {
arrayIndex = Math.floor( Math.random() * arrPositiveYou1.length );
var nextString = checkPronoun();
nextString = capitaliseFirstLetter(nextString);
nextString = capitaliseLetterI(nextString);
nextString = capitaliseAfterFullStop(nextString);
nextString += ".";
fontCall(defaultFont);
console.log(affirmationText.className + " class name ");
affirmationText.innerText = nextString;
  console.log(arrayIndex);
}

function checkPronoun() {
      if ( selectedPronoun == "You" ) {
        return changePronoun(replaceYou, arrPositiveYou1);
      } else if ( selectedPronoun == "She") {
        return changePronoun(replaceShe, arrPositiveShe1);
      } else if ( selectedPronoun == "I" ) {
        return changePronoun(replaceI, arrPositiveYou1);
      } else if ( selectedPronoun == "They" ) {
        return changePronoun(replaceThey, arrPositiveYou1);
      } else if ( selectedPronoun == "He") {
        return changePronoun(replaceHe, arrPositiveShe1);
      }
}

function changePronoun(pronounArr, arr) {
      var string = arr[arrayIndex].toLowerCase();
      console.log(string);
/*    commenting out name
    if ( name !== "" && string.indexOf("pronoun1") === 0 ) {
          if ( pronounArr === replaceShe || pronounArr === replaceHe ) {
            string = string.replace("pronoun1", capitaliseFirstLetter(name) + " is" );
          }
          if ( pronounArr === replaceThey ) {
            string = string.replace("pronoun4", capitaliseFirstLetter(name) + " is" );
          } else {
          for ( var k = 0; k <= replacements.length; k ++ ) {
            string = string.replace(replacements[k], pronounArr[k]);
            console.log(string);
          }
          }
        }
        else { */
      /* pass function string + pronoun?*/
        for ( var k = 0; k <= replacements.length; k ++ ) {
          string = string.replace(replacements[k], pronounArr[k]);

          console.log(string);
          }
        /*}*/

      /* * cycle through all words,
           * replace instances of each array index with another array index
        */
        return string;
      }

function insertName() {
  var input = document.getElementById("name-input");
  name = input.value;
  console.log(name);
}

/* font changing stuff
font-family: 'Monospace', sans-serif;
font-family: 'Bungee Inline', cursive;
font-family: 'Amita', cursive;
font-family: 'Lobster', cursive;
font-family: 'Indie Flower', cursive;

randomise
scripts.js:20 amita
scripts.js:20 lobster
scripts.js:20 bungieinline
scripts.js:20 indieflower
scripts.js:20 monospace
*/

function changeFont() {
    console.log("changeFont called");
    defaultFont = this.value;
    return fontCall(defaultFont);
}

function fontCall(font) {
  console.log("fontCall called");
  if ( font === "monospace") {
    return affirmationText.className = "monospace";
  } else if ( font === "indieflower") {
    return affirmationText.className = "indieflower";
  } else if ( font === "bungieinline") {
    return affirmationText.className = "bungieinline";
  } else if ( font === "lobster") {
    return affirmationText.className = "lobster";
  } else if ( font === "amita") {
    return affirmationText.className = "amita";
  } else if ( font === "randomise" ) {
    randomiseFont(numNum);
  }
}

function randomiseFont(ranNum) {
  console.log("randomiseFont called");
  ranNum = Math.floor(Math.random() * 5);
  console.log(ranNum + " random");
  if ( ranNum === 0 ) {
    return fontCall("monospace");
  } else if ( ranNum === 1 ) {
    return fontCall("indieflower");
  } else if ( ranNum === 2 ) {
    return fontCall("bungieinline");
  } else if ( ranNum === 3 ) {
    return fontCall("amita");
  } else if ( ranNum === 4) {
    return fontCall("lobster");
  }
}

function generateRandom() {
  console.log("randomise called");
 numNum = Math.floor(Math.random() * 5);
 console.log(numNum);
 return randomiseFont(numNum);
}
/* string modification */

function capitaliseFirstLetter(string) {
  string = string[0].toUpperCase() + string.slice(1);
  return string;
}

function capitaliseAfterFullStop(string) {
  if ( string.indexOf(".") !== -1 ) {
      var periodIndex = string.indexOf(".");
      if ( string.charAt(periodIndex+1) !== "." ) {
      string = string.slice(0, periodIndex + 2 ) + string.charAt( periodIndex + 2 ).toUpperCase() + string.slice( periodIndex + 3 );
    }
  }
  return string;
}

function capitaliseLetterI(string) {
  return string.replace(" i ", " I ");
}

/* event listeners */
changeAffButton.addEventListener("click", changeAffirmation);
document.addEventListener('keypress', function (enter) { var key = enter.which || enter.keycode; if ( key == 13 ) { return changeAffirmation();} })
/* addNameButton.addEventListener("click", insertName);*/
/* console.log(arrPositiveYou1[70]); */
/*
<h5>If choosing she, he or they you may optionally input your name.</h5>
<input type="text" id="name-input"></input><button id="add-name-button">Add name.</button>
*/
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.