Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9416711
finished project
deytonk Oct 6, 2017
76b1fd1
working rock paper scissors
deytonk Oct 7, 2017
4fdf6b0
passing all the tests, thank you Eddie and Stu :coffee:
deytonk Oct 17, 2017
f88fe57
initial commit in new branch
deytonk Oct 17, 2017
d6168f0
attempt 2
deytonk Oct 17, 2017
e0b4153
white boarding pig latin :octocat:
deytonk Oct 17, 2017
a51895c
find position of first vowel :boom:
deytonk Oct 17, 2017
76e2d97
converted my code from repl to work in the function provided in the j…
deytonk Oct 17, 2017
1052342
made some corrections to code :ghost:
deytonk Oct 17, 2017
8c591df
passing 2/4 tests, so added trim method and now passing 3/4 tests! :t…
deytonk Oct 17, 2017
2a7c0e3
I messed up and edited both rock paper scissors and datatypes in my p…
deytonk Oct 17, 2017
5bd60eb
passing all 4 tests
deytonk Oct 18, 2017
4286149
confused :flower:
deytonk Oct 25, 2017
6435190
Merge branch 'gh-pages' of https://github.com/deytonk/javascript-work…
deytonk Oct 29, 2017
0ecb11e
finished project
deytonk Oct 6, 2017
e665756
working rock paper scissors
deytonk Oct 7, 2017
bbfc340
merge conflict
deytonk Oct 29, 2017
2012252
initial commit in new branch
deytonk Oct 17, 2017
a3a18d5
attempt 2
deytonk Oct 17, 2017
b7100c4
white boarding pig latin :octocat:
deytonk Oct 17, 2017
8b660c0
find position of first vowel :boom:
deytonk Oct 17, 2017
8220632
converted my code from repl to work in the function provided in the j…
deytonk Oct 17, 2017
6f72a36
made some corrections to code :ghost:
deytonk Oct 17, 2017
b9f3ce0
passing 2/4 tests, so added trim method and now passing 3/4 tests! :t…
deytonk Oct 17, 2017
9cfb212
I messed up and edited both rock paper scissors and datatypes in my p…
deytonk Oct 17, 2017
e49199c
passing all 4 tests
deytonk Oct 18, 2017
341463a
merge
deytonk Oct 29, 2017
da1b8bd
Minimal
deytonk Nov 14, 2017
d3e5bcc
made corrections to pig latin
deytonk Nov 25, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 43 additions & 35 deletions 01week/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function day_time() {
console.log(weekday[today.getDay()] + " " + hour + ":" + min + ":" + sec);
}


day_time ();

function convertNumber() {
Expand Down Expand Up @@ -110,52 +111,59 @@ console.log(typeof object1);
var object2 = 7;
console.log(typeof object2);

// homework
// var number = 72468;
// number.toString();

// I did not even try prompt but I am assuming it wont work because it will return a string
// BUT if you parse the prompt it works!!!
var firstNum = parseInt(prompt("Write a number"));
var secondNum = parseInt(prompt("Write another number"));
console.log("The sum of your two numbers is " + (firstNum + secondNum));
const numberToString = (x) => {
x.toString();
}

// Renee wanted the program that adds two numbers in a function
var a;
var b;
// var string = "72468"
// parseInt(string);

function add(a, b) {
return a + b;
const stringToNumber = (x) => {
return parseInt(x);
}
console.log(add(10, 5));

// will run if both things are true
function willItRun(thing1, thing2) {
if (thing1 === true && thing2 === true) {
return "Yes it will run!";
} else {
return "Sorry, your function is broken.";
}
// this does not work because no matter what you write in the prompt the computer reads it as a string
// var object = prompt("Write an example of a datatype");
// document.write(typeof object);

const whatKindOfDataType = (x) => {
document.write(typeof x);
}
>>>>>>> 5bd60ebe9c867cc26fca388446688ad54f6ded84

Choose a reason for hiding this comment

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

Please remove


console.log(willItRun(true, true));
// homework

// will run if at least one thing is true
function howAboutNow(thing1, thing2) {
if (thing1 === true || thing2 === true) {
return "Yes it will run!";
// I did not even try prompt but I am assuming it wont work because it will return a string
const sum = (firstNum, secondNum) => {
document.write(firstNum + secondNum);
};

var thing1 = true;
var thing2 = true;

function willItRun (thing1, thing2) {
if (thing1 && thing2) {
return "both are true";
} else {
return "Sorry, your function is broken.";
return false;
}
}
};

console.log(howAboutNow(true, false));

// will run if both things are false
function lastOne(thing1, thing2) {
if (thing1 === false && thing2 === false) {
return "Yes it will run!";
function howAboutNow (thing1, thing2) {
if (thing1 || thing2) {
return "one is true";
} else {
return "Sorry, your function is broken.";
return false;
}
}
};

console.log(lastOne(false, false));
function lastOne (thing1, thing2) {
if (!thing1 || !thing2) {
return "both are false"
} else {
return false;
}
};
51 changes: 47 additions & 4 deletions 01week/rockPaperScissors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,44 @@ const rl = readline.createInterface({
output: process.stdout
});

function rockPaperScissors(a, b) {

function rockPaperScissors(hand1, hand2) {
// trim and convert characters to lowercase
const hand1 = a.trim().toLowerCase();
const hand2 = b.trim().toLowerCase();

// Write code here
// make sure players write the right words
// if ((hand1 !== "rock") && (hand1 !== "scissors") && (hand1 !== "paper")) {
// return "There was a typo, please try again!";
// }
//
// if ((hand2 !== "rock") && (hand1 !== "scissors") && (hand1 !== "paper")) {
// return "There was a typo, please try again!";
// }

const typo = ['rock', 'paper', 'scissors'];
if(typo.indexOf(hand1) > -1 && typo.indexOf(hand2) > -1) {
// check for tie, if a tie does not return - check for a win
if (hand1 === hand2) {
return "It's a tie!";
} else {
// write out all of the hand1 winning combinations
if ((hand1 === 'rock' && hand2 === 'scissors') || (hand1 === 'scissors' && hand2 === 'paper') || (hand1 === 'paper' && hand2 === 'rock')) {
return "Hand one wins!";

// if hand1 does not win then hand2 wins
} else if ((hand1 === 'rock' && hand2 === 'paper') || (hand1 === 'scissors' && hand2 === 'rock') || (hand1 === 'paper' && hand2 === 'scissors')) {
return "Hand two wins!";
}
}
} else {
return "There was a typo, please try again!";
}
}

function getPrompt() {
rl.question('hand1: ', (answer1) => {
rl.question('hand2: ', (answer2) => {
rl.question('Player 1: ', (answer1) => {
rl.question('Player 2: ', (answer2) => {
console.log( rockPaperScissors(answer1, answer2) );
getPrompt();
});
Expand All @@ -43,6 +71,21 @@ if (typeof describe === 'function') {
assert.equal(rockPaperScissors('Paper', 'SCISSORS'), "Hand two wins!");
assert.equal(rockPaperScissors('rock ', 'sCiSsOrs'), "Hand one wins!");
});
it('should detect when hand 1 wins', () => {
assert.equal(rockPaperScissors('rock', 'scissors'), "Hand one wins!");
assert.equal(rockPaperScissors('paper', 'rock'), "Hand one wins!");
assert.equal(rockPaperScissors('scissors', 'paper'), "Hand one wins!");
});
it('should detect when hand 2 wins', () => {
assert.equal(rockPaperScissors('rock', 'paper'), "Hand two wins!");
assert.equal(rockPaperScissors('paper', 'scissors'), "Hand two wins!");
assert.equal(rockPaperScissors('scissors', 'rock'), "Hand two wins!");
});
it('should detect a typo', () => {
assert.equal(rockPaperScissors('sizzors', 'paper'), "There was a typo, please try again!");
assert.equal(rockPaperScissors('rock', 'pepar'), "There was a typo, please try again!");
assert.equal(rockPaperScissors('rokk', 'pepar'), "There was a typo, please try again!");
});
});
} else {

Expand Down
44 changes: 0 additions & 44 deletions 02week/exercises.js

This file was deleted.

31 changes: 28 additions & 3 deletions 02week/pigLatin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,41 @@ const rl = readline.createInterface({
});


function pigLatin(word) {
const pigLatin = (word) => {

// Your code here
//making sure I made my branch correctly, attempt 2 https://github.com/deytonk/javascript-workbook/pull/5

// WHITE BOARDING:
// Find position of first vowel (a,e,i,o,u, or y)

let pigWord = word.trim().toLowerCase().split('');

// This regex string method is used to parse and iterate through the characters of the parameter of the pigLatin function, to see where the vowels are located.
// const firstVowel = word.match(/[aeiouy]/);
// const firstPosition = word.indexOf(firstVowel);

const vowel = ['a', 'e', 'i', 'o', 'u'];
// If vowel is the first letter of the word, return the word with 'ay' at the end, (unless Y is the first letter, then treat as other words)
if (vowel.indexOf(pigWord[0]) > -1) {
return pigWord.join('') + "yay";
// For all other words, return any letters before the vowel to the end of the word with 'ay' at the end, moving the first vowel to position 0
} else {
for (let v = 1; v < pigWord.length; v++) {
if (vowel.indexOf(pigWord[v]) > -1) {
return pigWord.slice(v, pigWord.length).join('') + pigWord.slice(0, v).join('') + "ay";
}
}
// pigWord.forEach(vowel.indexOf(pigWord[]))
// return pigWord.splice(0, ) + "ay";
}
}

// pigLatin('thrice');


function getPrompt() {
rl.question('word ', (answer) => {
console.log( pigLatin(answer) );
console.log(pigLatin(answer));
getPrompt();
});
}
Expand Down
Loading