Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 13 additions & 4 deletions 02week/pigLatin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ const rl = readline.createInterface({


function pigLatin(word) {

// Your code here

}
let inputArray = word.split('');
let vowelArray = ['a','e','i','o','u'];

Choose a reason for hiding this comment

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

Nice data setup here.

for(let i =0; i<inputArray.length;i++){
const letter = inputArray[i];
if(vowelArray.indexOf(letter)!== -1){
const cutPiece = inputArray.slice(0,i)
const remainingArr = inputArray.slice(i)
const theEnd = remainingArr.concat(cutPiece);
console.log(theEnd.join('') + 'ay');

Choose a reason for hiding this comment

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

Please return instead of console.log

break;

Choose a reason for hiding this comment

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

Your app does not address instances when the first letter is a vowel.

}
}
}


function getPrompt() {
Expand Down
19 changes: 16 additions & 3 deletions 02week/ticTacToe.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const rl = readline.createInterface({
output: process.stdout
});
let board = [
[' ', ' ', ' '],
[' ', ' ', ' '],
[' ', ' ', ' ']
array1: [' ', ' ', ' '],
array2: [' ', ' ', ' '],
array3: [' ', ' ', ' ']
];

let playerTurn = 'X';
Expand All @@ -25,14 +25,27 @@ function printBoard() {

function horizontalWin() {
// Your code here
if (array1===[x,x,x]||[o,o,o]){
return "Win!";
}else if (array2===[x,x,x]||[o,o,o]) {
return "Win!"
}else if (array3===[x,x,x]||[o,o,o]) {
return "Win!"
}
}

function verticalWin() {
// Your code here
if (array1[0]===x||o && array2[0]===x||o && array3[0]===x||0){
return "Win!"
}
}

function diagonalWin() {
// Your code here
if (array1[0]===x||o && array2[1]===x||o && array3[2]===x||o){
return "Win!"
}
}

function checkForWin() {
Expand Down