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
24 changes: 18 additions & 6 deletions 02week/pigLatin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,27 @@ const rl = readline.createInterface({


function pigLatin(word) {

// Your code here

}

let inputArray = word.split('');
let vowelArray = ['a','e','i','o','u'];
for(let i =0; i<inputArray.length;i++){
//console.log(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');

//console.log(cutPiece, inputArray);
//return finalStr
break;
}
}
}

function getPrompt() {
rl.question('word ', (answer) => {
console.log( pigLatin(answer) );
pigLatin(answer)
getPrompt();
});
}
Expand Down
8 changes: 8 additions & 0 deletions 04week/algorithms.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ for (let i = 0; i < 1000; i++) {

function bubbleSort(arr) {
// Your code here
for (let i =0; i < arr.length; i++){
if (arr[i] > arr[i+1]){
let temp = arr[i]
arr[i] = arr[i+1];
arr[i+1] = temp;
}
}
}
console.log(bubbleSort(arr));

function mergeSort(arr) {
// Your code here
Expand Down
1 change: 1 addition & 0 deletions 05week/checkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const rl = readline.createInterface({

function Checker() {
// Your code here

}

function Board() {
Expand Down
33 changes: 33 additions & 0 deletions 05week/spaceTravelToMars.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,40 @@ let jobTypes = {
};

// Your code here
class CrewMember{
constructor(name, job, specialSkill){
this.name = name;
this.job = job;
this.specialSkill = specialSkill;
this.ship = null;
}
enterShip(ship1){
this.ship = ship1;
this.ship.crew.push(this);
}
}

class Ship{
constructor(name, type, ability){
this.name = name;
this.type = type;
this.ability = ability;
this.crew = [];
}
missionStatement(){
if (this.crew.length >0){
return this.ability;
}else{
return 'Can\'t perform a mission yet.'
}
}
}
/*const crewMember1 = new CrewMember('Chase','commander','being radical','');
const crewMember2 = new CrewMember('Julian','pilot','stylist','');
const crewMember3 = new CrewMember('Rick','mechanic','sharpshooter','');
const crewMember4 = new CrewMember('Cora','programmer','talking shit','');
const mav = new Ship('Mars Ascent Vehicle','MAV','Ascend into low orbit');
const hermes = new Ship('Hermes','Main Ship','Interplanetary Space Travel');*/
//tests
if (typeof describe === 'function'){
describe('CrewMember', function(){
Expand Down