20 February 2017

Frontend skills test


A while ago I applied for a post without realising it was for a senior position rather than a junior one.... It was the last day to apply when I found it so I didn't check - I just submitted my application.

In any case I was then given a test to do via GitHub - I was going to clone it but I realised perhaps adding my answers where they were find-able by others doing the same test might not be the best idea. I must have done the test correctly because I got to the interview stage which I didn't do so well in - I prepared for completely the wrong type of question. I worked pretty hard on this so I'd like for it to exist somewhere.

So! Here are my answers!
# Technical skills test

This front end development test is intended to cover a broad range of skills
required to deliver high quality government digital services. This includes:
* Accessibility
* HTML
* CSS
* jQuery and JavaScript
* Other best practices 

Candidates are asked to perform this test remotely and submit their responses to the sender.

## Accessibility

1. Describe how you would implement the page available at http://calendar.parliament.uk

    Focus specifically on not disadvantaging users of:
    
        1. Assistive technology
        2. Older/less featured browsers

Your answer should describe both how you would do this and describe what specific features
of HTML, ARIA, CSS and JavaScript you would use to achieve this.

---
Firstly it is important to use a logical structure for the DOM and decide on semantic elements for each section of the page.
For this page I can see a header, navigation, sub-navigation pages, breadcrumbs and then two main sections with an aside followed by a 'share' section and a footer.

While using HTML5 semantic elements such as `[aside]` is useful for those with accessibility needs this can mean that those using older browsers are unable to display the page correctly.
All pages with HTML5 elements should also be styled with `display:block` as well as include the W3C `html5shiv` javascript file to ensure compatibility across browsers.

**Navigation Elements**: Should use unordered lists and the `tab-index` attribute. As there are multiple `nav` elements on this page it may be less semantically confusing to define a number of navigation divs while also using the `aria role` attribute to make these easy to navigate.

**Calendar Elements**: Use `aria role` attributes for all `[div]` elements. Use CSS `:active` and `:focus` to identify where a user is on the page and ensure all browsers will be able to communicate that information to the user.
The date picker should be easy to tab through and use dropdowns for the month and year rather than making users pick a specific week from the last ten years.
Although HTML5 provides a `date` function this isn't supported by Firefox, Internet Explorer or Safari so a javascript datepicker should be included as a fallback.
Finally, when the date changes the information below should also change and use `aria-live` to alert the user to this change.

---

2. How would you implement a version of GOV.UK browse for a new digital service.

    Your answer should:
    
    1. identify, so far as possible, what GOV.UK have done to ensure accessibility and progressive enhancement
    2. assume you're approaching this from scratch

---
_Note: I understand GOV.UK to be a web portal for a number of user questions, GOV.UK then answers those questions and directs users to another site that helps a user complete a related action (ex paying council tax or claiming a benefit)._

The current GOV.UK service uses many best-practice methods to ensure both accessibility and progressive enhancement.

Firstly, it's immediately obvious that a lot of time has been spent on the UX / UI design of the site.
The contrasting colour and reliance on text formatting and document structure rather than images are useful to all users in terms of reduced pay-load but also to users with accessibility-needs as there is less of the page to navigate through. The text is also easy to read and scalable.

The order of the navigation and the 'popular' section try to answer your query without the user scrolling down the page, and therefore without a screen-reader or keyboard-only user having to get very far down the page.
The page is structured in an ordered way and is easy to navigate through a keyboard while for screen-readers the least useful elements have `aria-hidden` attributes.
Finally, the head of the document includes a number of tags that allow older browsers to access the site.

If approaching a similar project from scratch the first step would be user research to find out what information users would want to receive and which questions they want answered.
For a service that must be accessible and bring a number of elements under one domain and search index the design is the most important element.
The design of the page must be clear, re-usable and uncluttered to ensure that questions can be best answered through this portal rather than another. The focus should be on providing a clear, plain and accessible interface rather than one with a cutting-edge design.

To that end a number of standards should be put in place after a heavy amount of research into what users want to get out of the platform.
After these standards the content and writing should also be a key focus of the project that answers questions directly rather than through jargon and technical language.

---

## JavaScript and jQuery

1. An exercise using jQuery is provided in test-jquery.html.
---
_Note: I was asked to include my answer in the document_
```
[!DOCTYPE html]
[html]

[head]
 [script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"][/script]
 [meta charset=utf-8 /]
 [title]DOM manipulation exercise[/title]
[/head]

[body]
 [h1]DOM manipulation using event delegation[/h1]
 [p]Using event delegation write the jQuery or JavaScript that will hide the <li> element that is clicked on. Any subsequent clicks should have no effect.[/p]
 [p]Please do not edit the HTML or CSS directly to achieve this.[/p]
 [div]
  [h2]First set[/h2]
  [ul]
   [li]HTML5[/li]
   [li]CSS[/li]
   [li][span class="highlight"]JavaScript[/span][/li]
   [li]Ruby[/li]
   [li]Django[/li]
   [li][span class="highlight"]React[/span][/li]
  [/ul]
 [/div]
 [script type="text/javascript"]
  $("li").click(function () {
   $(this).hide();
  });
 [/script]
[/body]

[/html]
```
---

2. If you saw this in a Pull Request, what would your advice be:

 ```
 Array.prototype.split = function(i) { // Adds split to all arrays
    return [this.slice(0, i), this.slice(i)];
};
 ```
---
* Move the comment to a new line.  
* Change the name of the function to avoid confusion with `string.prototype.split`. Suggest `array.prototype.segment`
---

## CSS

1. What colour would each of the following elements be (Assume each pair of rules are targeting the same element)
 ```
h1 {color: red;}
body h1 {color: green;}

h2.grape {color: purple;}
h2 {color: silver;}

html ] body table tr[id="totals"] td ul ] li {color: maroon;}
// li has an id of answer
li#answer {color: navy;}
 ```
---
From the rules given those with greater specificity would determine the colour of the element:
 ```
body h1 {color: green;}
h2.grape {color: purple;}
html ] body table tr[id="totals"] td ul ] li {color: maroon;}
 ```
---
2.Given the HTML below, write a CSS3 rule that will give prepend the text ‘Tel:’ to the third list item.
You are not able to amend the HTML to achieve this.
 ```
[body]
  [ul]
    [li]JavaScript[/li]
    [li]HTML[/li]
    [li]Ruby[/li]
    [li]Python[/li]
  [/ul]
[/body]
 ```

---
My rule:
 ```
li:nth-child(3):before {
content:"Tel: ";
}
 ```
---
3.What changes would you suggest to make these CSS rules ready for a production environment?
 ```
[!DOCTYPE html]
[html]
    [head]
    [meta charset=utf-8 /]
    [title]Test[/title]
      [style type="text/css"]
        #one { background-color: #000; }
        .three { color: rgba(255,255,255,1); }
        div ] span { border: 3px solid green; }
      [/style]
    [/head]
    [body]
      [div id="one"]
        [div class="three"]
          Hello [span]World![/span]
        [/div]
      [/div]
    [/body]
[/html]
 ```

---
* Move the css into a new file
* Give the body a background colour
* Standardise the colour codes used. There doesn't seem to be a reason to use rgba colour codes.
3 digit hex could be used but if more code were to be added later 6 digit hex may be required.
```
       #one { background-color: #000000; }
       .three { color: #ffffff; }
       div ] span { border: 3px solid #008000; }
```
---
4. How would you style all links to 'gov.uk' domains differently to other links in an application?

---
Assuming there are more gov.uk links than other links I would use:
```
a {color:green;}
a:not([href*="gov.uk"]) {color:blue;}
```
If there fewer gov.uk links than other links I would use:
```
a {color:blue;}
a[href*="gov.uk"] {color:green;}
```

---

## HTML
1. A test using HTML5 is provided in test-html.html within this repository.
Please amend the code and submit your changes as a pull request.

---
_Note: I was asked to include my answer in the document_
```
[!DOCTYPE html]
[html]
  [head]
    [meta charset= utf-8 /]
    [title]DOM manipulation - Test 5[/title]
    [style type="text/css"]
        body {
          font-family: sans-serif;
          font-size: 1.5em;
          line-height: 1.5em;
        }

        div {
          margin-bottom: 1em;
          padding: 1em;
          background: #EFEFEF;
        }
  [/style]
  [/head]
  [body]
      [h1][span class="first"]HTML5 test[/span][/H1]
  [p]The HTML of this page contains a number of errors. Please amend the source code to remove these errors and paste an improved version into the worksheet.[/p]
  [p]Please limit changes to errors that relate to HTML5 only. Do not:[/p]
      [ul]
    [li]Make changes that might fix an issue in XHTML, but are [strong]not relevant to HTML5[/strong][/li]
    [li]Make stylistic changes that are not relevant to the [strong]specification[/strong][/Li]
      [/ul]
  [/Body]
[/html]
```

## Testing

1. What are the key things you need to test for on the front-end of digital services?
---
* Usability / functionality
* Accessibility
* Page Speed / Load Time (depending on audience connection speed)
* Browser compatibility (depending on audience browser)
* Mobile Compatibility

---
2. How do you approach testing the front end of applications?
---
I first make sure that everything is working as it should, tabbing through options to make sure the user path is clear and simple.
I use a different browser than I would usually do this in - Usually Internet Explorer and then Firefox with ad-blocker installed.
When possible I also ask a less-technically minded friend or colleague to test the application to make sure I'm not overlooking the obvious.
I then use Chrome Accessibility Development Tools to make sure everything that needs to have an `aria` label has one and the whole page can be navigated through the keyboard.

Once assured of  basic functionality I then use Chrome Developer Tools to check for 3G connection speeds and common viewport sizes.
Using data gathered about the type of audience I will then check compatibility with any other browser or connectivity needs.

Finally I'll run the page through the W3 Markup Validator to check for missing tags or text and the Web Accessibility Checker for any final problems.

---

## Best practices

1. Is this good quality code? Provide a brief justification of your answer.
 ```
  [button
    type="button"
    onclick="document.getElementById('xyz').style.color='red';"]
      Click Me
  [/button]
 ```
---
I wouldn't say this is good quality code.
As everything is being applied inline it would be difficult to reuse and re-apply this code.
The javascript and css should be moved to different files and applied to the element using either a class or id depending on how the button is used.  

On the positive side, it's good that the developer has used the button element rather than a div and has used `type="button"` to show there is no form behaviour associated with the button for cross-browser compatibility.

---
2. Describe three ways to decrease page load time (answers may include perceived or actual load times)

---
1. Minify and combine external files:  
Each external resource has to be requested by the browser. By combining files just before production, fewer files have to be loaded before the page can be displayed.
Minifying the files decreases the size of the file and thus the time it takes to download. Deleting superfluous code will also help reduce the filesize.

2. Optimise and scale image sizes using the `srcset` attribute:  
Images are one of the biggest causes of page load delay as they can be very large files even when a file of that size is not necessary.
Here are some ways that optimising images can be done:
    * Only use images when necessary - don't rely on images to make sense of a layout and use SVG elements when possible.
    * Optimise images so they are of the quality and size necessary.
    * `srcset` allows you to provide a number of images of different size and quality while allowing the browser to select the one most suited for the viewport.   
    As `srcset` is not currently supported by IE or mobile browsers other than Chrome so it's important to optimise and scale images despite this tag.
However `srcset` can be catered for by 82% of UK users as well as being part of the WHATWG living standard for HTML.

3. Optimise browser caching:  
Each external file should include `cache-control` and `eTag` headers that tells the browser how long a resource can be cached for and check if the resource has changed since it was last accessed.
This will reduce page load time for users who routinely visit the site.

---

3. Why is it generally a good idea to position CSS  `[link]` s between  `[head][/head]`  and JS  `[script]` s just before  `[/body]` ? Do you know any exceptions?

---

**CSS** is usually positioned between `[head][/head]` so that styles can be applied to `[body]` content as it loads.
If a stylesheet were loaded further down the page it may result in elements moving around or fonts changing as a user navigates the page.
I'm aware that HTML5 allows `[link]`s inside the body when dealing with different pages with some common elements but other large differences in order to prioritise those common elements but I've not come across an example of this being used so I'm unsure which situations to use this in.  

**JS** is usually positioned just before `[/body]` as the files can sometimes be large.
Rather than waiting for the files to load placing them after the content of the page means a user will not be waiting for these files before they are able to view the page.
As these files usually augment the functionality of the page rather than define it loading content is prioritised. Where the file is central to the functionality of the page it is placed within the `[head]`.
It is also possible to place all files within the `[head]` but use `defer` and `asynch` tags to allow the main content of the page being loaded without waiting for the external files.

---



14 January 2017

Being proud of myself


There are two things I do at the start of a new year.

One is a Lifehacker review of my previous year. I actually can't find the original article but the questions I answer every year are:

  • What went well
  • What accomplishments did I have?
  • How did I improve my life?
  • How did I improve my relationships?
  • What did I remove from my life that is now making me happier?
  • What do I wish I had taken more time for?

My reviews have their own folder in my Google Drive

The second thing I do (or have done for the past couple of years) is a Buzzfeed Memory Jar.

I've actually been feeling very down about the past few months. On top of wedding related stress I'm leaving BrexitCentral at the end of the month - which was planned from the start but I think it's going to be my last job in Westminster and that's left me feeling very conflicted. So today, when I finally felt like I could sit down and do my review of last year I opened up my memory jar and started unfolding the little bits of paper that I'd kept for a whole year.

And it made me very happy.

Sometimes I've written the same achievement twice because it made me so happy. Sometimes I achieved very small things that while being small made me feel accomplished at the time. Last year I wrote down the important ones in my review document and then burned them. This time I feel so overwhelmed - I started today feeling tired already and avoiding my year review because I wasn't sure what to put - I'm going to document them all here exactly as I wrote them before burning them. (Fiancé. If you're reading this I'm sorry in advance. I know that this is what you're supposed to use the shredder for.)

So, in categories but no particular order within those:

Life:

  • Stopped Grandma running a red light (18/02/16)
  • Got my Day Skipper Licence! (12/02/16)
  • Got my Day Skipper Licence! Not Comp Crew! <3 li="">
  • Lay my hands flat on the floor after Yoga!
  • Got free pizza from the lovely people @ Papa Johns! (24/11)
  • Cleaned the washing machine filter
  • Went to see "Your Name" - cried a lot (24/11)
  • Unblocked bathroom sink

Social / Courage:

  • Darren said I was a very social person
  • Called Yoko and had a kinda conversation in Japanese (08/12)
  • I asked the couple to move during the last act of the Cursed Child as I couldn't see the stage properly - and they did! (16/09/16)
  • Told JI I didn't want to work at BC long term (17/08)

Work:

  • My licence fee lines document was deemed super helpful by Dia and Alex. John said they should be a permanent reactive work feature (13/05/16)
  • JI says my social media presentation work is first class work (11/03/16)
  • Jonathan said I get shit done (01/12)
  • John approved me working with the interns and thought my prep work was awesome. Kate thought it was helpful too! (14/05/16)
  • My volunteer planning guide is AWESOME (Says KG) (13/05)
  • Correctly moved our WP hosting (25/11)
  • Worked really hard on the Steel Briefing in terms of organising so Alex was freed up to write. Also updated social media & website v. soon after publishing (01/04)
  • JO and AW both like my adaption of JSJs research note template. It both looks good and is workable for everyone! (27/04/16)
  • Built a clean version of Your TPA within 30 mins after realising there were some errors on my Saturday build. (22/08)
  • FINISHED TPA APP!
So - even if I didn't manage to achieve one important thing a day, or one important thing a week, I feel pretty proud of myself right now. I'm going to go and write my review.


Source: ZeroChan






18 November 2016

*~*~New Project~*~*



Apologies for the overexcitement. I'm just very happy since it's been a long time since I started anything new.

This is project left-yet. As in "Have they left yet?" I thought it might be something vaguely fun and it might give me a good mix of new and old things to work on.

The aim for this project is to create a responsive database of everyone who said they'd leave the country when x happens. I realised soon after creating the table that this leaves no room for Gary Linker and his ilk so I'll have to have a think about that.

Anyway, the point is to use responsive table design, Firebase and AngularJS. Screengrab of a few hours work below. Angular works, I found a good tutorial on responsive tables that I've ripped off and I have Firebase kinda set-up. I've stopped today because I've broken it but I think I did something very specific that makes that my own fault.

Hopefully I come back to this sooner rather than later.


3 November 2016

Post-TPA Projects

JUST IMAGINE YOU'RE OUT THERE!
Image from PersonaCentral.com

Somehow I'm currently deputy-editor/digital manager at BrexitCentral!

Apart from creating a very early-days website (which I forgot to screenshot and has since been lost I had a backup in an obscure corner of my computer. Will add a screenshot at the bottom) there hasn't been much coding going on. That early-days website wasn't more than a placeholder with an email signup and some info about BrexitCentral but I built it in a day using Bulma.io to get it started. This is actually the second time I've used that framework - because of the way it's put together it's really easy to make something pretty but simple. It's much more lightweight than Bootstrap as well.

In other news:
YourTPA is finally available on the app store! Although I'm not as proud of it now as I was in the past.... I've moved on considerably since this was completed...

I've been learning more about Photoshop under the tutelage of new colleague Darren Grimes. As in all cases where you learn something new I shudder to think about the ways I was going about things in the past. I'm particularly enamoured with the pen tool and colour replace feature.

Japanese is back on the agenda again. Mostly due to many, many hours being spent playing Persona 5. Although it's been pointed out that the vocab lists I'm making during my playtime aren't particularly coherent.

This week's vocab list for example:

汝 (Thou)
容態 (Condition / State)
もやもや (Foggy / Gloomy)
ウソ泣き (Crocodile tears)
黙秘  (Silence regarding a subject)

Told you it wasn't exciting

21 August 2016

Latest Projects

I realised my project update list has dragged on so here's how everything is going.

TPA Project
I'm actually leaving the TPA at the end of the month! At the time I decided to quit without having another job to go to and planned to take a long break in order to focus on my front-end skills. However since then I've been lucky enough to have been offered another job! So I've already done a little for that but I'll be working on it properly in September.

In any case one of the last things I have to wrap-up at the TPA is this application. Although I didn't use all the material design patterns that I wanted to I'm pleased to say that this is all done BUILT (which took me forever) and uploaded to the app store (without being published) as of yesterday.

Although on my way home I was playing with the version I installed on my phone and realised I forgot to include an icon so will have to suffer through re-building the whole thing again *cries*. Looking at it now that's the working title of the app rather than the actual title as well... *sigh*

In any case - here's what it looks like!



I'm just quite glad it's nearly over to be honest... It was difficult to find time to work on between everything else - I can't believe I've been working on this since January and this is all I have to show for it.....


Debt Clock Project
At some point the Twitter Debt Clock stopped working. I wasn't able to figure out why it was broken and eventually decided to give up in favour of the aforementioned project. Then debt-clock.org stopped working and I can't access the server :/

Perfect time to just rip everything out and start again!

Old Site

New Site! Using the Bulma.io framework

Further down the old site with the JS working
Well - there's more than a couple of things to add and I'm not happy with the design (there's a list of things that need adding) but the new site has a tiny filesize compared to the old one and looks much better on mobile (didn't think to take that screenshot...)

So - I have 1 week left at the TPA. I wonder if I can finish this and get the Twitter-bot working again in that time.

Beck-Allan's
Last one! This is actually something I did as a challenge. I had 3 hours to fill and wanted to see how far I got. Beck-Allan's are already in the middle of a web-changeover so there's no way this project will go any further.

Old website

New website! It's a little grid-y but it has everything

Icons from Font Awesome

I'm not particularly proud of this one because the fonts, colours and otherwise don't really fit together but the most important thing is that all the information is on one page (even on mobile! And again I forgot to take that screenshot....).

When sketching from the old / current website there were a number of small pages with a number of images and a little text for each of the apartments and I thought that would be better handled with a gallery. All the relevant information about the apartment is now right by the picture and I tried to standardise it as well (ie rating, how many people, charm points).

And that's it! All my projects from the last month - and I'm really hoping I'll get to work on some more fun stuff very soon!

12 June 2016

Weddings are hard

You may have missed it but in November 2014 Matthew and I got engaged!

(Not us - just wanted to use this picture!)

Since then we had more than a year of doing very little about it as moving in together and starting new jobs made our life quite busy. What I was most excited about though was the website - at the time Matthew was studying HTML and I had just discovered the CSS Zen Garden so I was already thinking about what information should be on the site.

We knew we'd have a smaller budget so what we wanted was a place where all the information could sit rather than using thousands of bits of paper - through the colours, fonts and images we also wanted to convey what kind of style and level of formality we were expecting. As far as concrete design principles go all the information should be on one page and the layout should be responsive.

Design 1

Here's my initial design. Right at the top you can see my biggest concern was that my email was nowhere on the page. Eventually I set it up info@jordanandmatthew.com to get around that problem although js-mailer seemed like a good solution as well.

When I started building it - this design looked terrible. It was cluttered and the images weren't in a consistent format. So:


Design 2

Much better! The content hasn't changed and the layout hasn't changed that much but everything is more consistent.

And here's the finished product!

Sorry for the rough quality. Enabled by ScreenToGif

The most difficult / fun part was probably working out the flexbox on the "wedding party" section. After my 3rd attempt at "width: x%; float: left;" refused to work I remembered reading about flexbox in .Net Magazine and looked into it a little more. I still don't completely understand how to use it but it was very helpful in this case!

There's still a whole section 'Schedule' missing at the moment because we still haven't confirmed the timings of the day and what kind of ceremony it will be. Originally (you can see in the wireframes) I thought this should be a parallax scroll element that adds items as you scroll down but as I couldn't think of another use for this feature maybe it would be jarring to add it in just for one section?

I suppose I'll just have to try it and see!

4 May 2016

Which Waste Item are You? - Adventures in Javascript

I'm really interested in the 'quiz trend'. I remember being 12 and taking a number of quizes that would purportedly tell me "Which character from your favourite TV show are you?" or "What percent elf are you?" or "What were you in your past life?". Buzzfeed is now king of the quizzes. You can find out basically anything about yourself in the buzzfeed quiz section.

Sidenote: I read a theory somewhere that this obsession with quizzes is to do with population growth. Ie. Back when you were the only baker in the village you knew who you were and how you were different to everyone else. Now you have to differ yourself from the rest of the planet by placing yourself into the middle of a venn-diagram that you make smaller and smaller through quizzes.


Sidenote 2: I'm Saturn.

So - I thought the TaxPayers' Alliance could really benefit from one of these. Because everyone likes personality quizzes. So here it is!

This was a lot of fun to puzzle through! It took me a couple of days to write the content, figure out the personalities and what 'IT waste' should have in its wallet. Then I added the images and css because that's the fun part.
// Onclick disable future clicks and increment variables
  $('input').click(function() {
    if ($(this).parents('label').siblings('label').hasClass('finished')) {
    } else {
      $(this).parents('label').siblings('label').addClass('finished').css({'opacity':'0.6', 'cursor':'default'});
      if ($(this).hasClass('alpha')) {
        answersArray[0]++;
      } else if ($(this).hasClass('bravo')) {
        answersArray[1]++;
      } else if ($(this).hasClass('charlie')) {
        answersArray[2]++;
      } else if ($(this).hasClass('delta')) {
        answersArray[3]++;
      } else if ($(this).hasClass('echo')) {
        answersArray[4]++;
      } else if ($(this).hasClass('foxtrot')) {
        answersArray[5]++;
      }; 
      total ++;
    };

That was the fairly straightforward part. The rest is guessable but it took me a while to puzzle-through. I tried a few different solutions before deciding to use an array. If you pick the answer that corresponds to Personality 1 that will increment array value 1. At the end of the questions the position of the highest value in the array is returned and matched to a Personality Index.

So at the end of the questions you may have returned: 3 'Personality 1' answers; 2 'Personality 2' answers; 1 'Personality 3' answers.
In that case the array will be [3,2,1] and the index number returned will be 0. This is then re-matched to 'Personality 1' and that will be your result.

Pretty simple. But what about when the array is [2,2,2]?

I looked at how Buzzfeed did their quizzes and realised that when there was a clash Buzzfeed was just choosing the one at the end of the array whereas I wanted the choice to be randomised between the clashes.

After much experimenting the way I solved this is rather long-winded.

//Figure out personality index
  var finalResult = function() {
    
    //Give the position of the number in the array that has the greatest value
    var finalAnswer = answersArray.indexOf(Math.max.apply(Math,answersArray));
    var finalAnswerValue = answersArray[finalAnswer];
    var compareArray = []; 
    
    
    //Push the index of items in answersArray that == the maximum points number
    for (var i = 0; i < answersArray.length; i++) {
      if (finalAnswerValue == answersArray[i]) {
        compareArray.push(i);
      }
    }
    
    // If there is nothing in the compare array go with the original answer if not select a random value from the compareArray
    if (compareArray.length === 0) {
      personalityIndex = finalAnswer;
    } else {
      personalityIndex = compareArray[Math.floor(Math.random() * compareArray.length)];
    }
  };
After searching for the highest number in the array and pushing that to a variable.
Another function then searches the array again for that value. The index number of that value is then pushed to a new array. If the new array only has 1 value in it then that 1 value is used as ther personality. If not then a random value is then selected from the new array!