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

Kyle Easton's Homework - 11/29/17 #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kjkeaston
Copy link

Comfort: 3/5
Completness: 4/4

Didn't really do anything on the beer bottle one as I got that working last time.

The prime one wasn't too bad to print the array, but it was printing lots of arrays building up to my max number adding an new array element each time. It took me a little bit to realize I should just move where my console.log was to only print the "last" array.

Had trouble with the palindrome. I got it to correctly mark true or false, but it seems like it is marking true or false multiple times based on each letter evaluation instead of just once for the whole word vs word. it is also giving a true with each false but trues come back alone

I feel pretty good about the insult generate. Had to look up the math.random as I didn't know how to select something random from an array. I like the way mine looks, but needed an HTML and CSS page to get what I wanted. The thing I spent the most time on was figuring out my prompt for how many insults was storing a string value and not a number. I spent forever re-writing code and just running one thing at a time and console.logging it all to see what each thing was coming back as. Once I just changed my === 1 to === '1' it worked how I wanted. In hindsight, I should have just done the typeof. Literally just thought of that....would have save some time.lol.

let arrayOfLetters = word.split("");
for (let i = 0; i <= arrayOfLetters.length; i++) {
if(arrayOfLetters[i] === arrayOfLetters[(arrayOfLetters.length - (i + 1))]) {
console.log(true);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we talk about functions more tomorrow & next week, we'll talk about why console.log is less useful here than using return, but it's good that you got this working!


let isPrime = function(num) {
if (num === 2 || num % 2 === 1) {
console.log(true);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, here it would be better to return this answer rather than console.loging it.

let primes = function(max) {
let primeArray = [];
for (let i = 2; i <= max; i++) {
if (i === 2 || i % 2 === 1) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this will add every odd number to your list of primes--remember to test on lots of interesting cases!

let randTwo = second_word[(Math.random() * second_word.length) | 0];
let randThree = third_word[(Math.random() * third_word.length) | 0];

let askName = prompt("Who is this scoundrel that needs insulting?", "Enter a name");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense you needed to add the HTML page to get these prompts to work--nice job going beyond the directions to complete the bonus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants