Skip to content

Instantly share code, notes, and snippets.

@bootcoder
Last active August 29, 2015 13:57
Show Gist options
  • Save bootcoder/9679869 to your computer and use it in GitHub Desktop.
Save bootcoder/9679869 to your computer and use it in GitHub Desktop.
// pseudo for u1_w2_c5.js
//
// write 3 functions to calculate the sum, mean and median of even and odd arrays
// create variable total and set equal to 0
//
// Sum
// create a function sum, that takes a single input as an argument.
//
// reset total to 0
// FOR loop i = 0, i< input.length, i++
// return total += input element i
// end FOR loop
//
// Mean
// create a function mean, that takes a single input as an argument
//
// reset total to 0
// set total to the return of calling the sum function on input
// return total divided by the length of input
//
// Median
// create a function median that takes a single input as an argument
//
// call sort on the input array
// create a variable half set it equal to the value of Math.floor given half the input length
// IF Loop
// given input length modulus = 1
// return element half of input array
// ELSE
// return the result of taking the average of, half the input array and half the input array + 1
// End IF Loop
// Reflections
// I was really happy to be the member assigned to do the pseudo for this challenge. Because I have very little experience with
// pseudo, I could really use the practice. And it showed. My first attempt was very no bueno.
// But with some council and a good bit of research I think my second attempt was far better. I defnitely struggled with
// the pseudo at first. I was too specific and my code outlay was too complicated. I really have to start thinking about
// whats the easiest way to do X.
// I learned several good things about pseudo, proper styling and good logic being at the top of that list.
// I did wind up coding out the challenge myself before I finished re-writing the pseudo.
// Just to make sure that I was good all around. As to the code I did finally have a small 'AHA' moment.
// I was interating through an array and adding the for incrementer instead of an array element to my totals. DUH! :+)
// Overall my group did well. Our final gist is all green so no complaints there.
// I feel like we communicated well and no one person took too much time to complete their part.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment