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

Unofficial/master #149

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions Review/reviewProblems.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
matrix
pyramid
stairs
27 changes: 26 additions & 1 deletion exercises/anagrams/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,31 @@
// anagrams('RAIL! SAFETY!', 'fairy tales') --> True
// anagrams('Hi there', 'Bye there') --> False

function anagrams(stringA, stringB) {}
function anagrams(stringA, stringB) {


let arr1 = stringA.replace(/[^a-zA-z]/g, '').split("")
let arr2 = stringB.replace(/[^a-zA-z]/g, '').split("")

let sorted1 = arr1.sort().join('').toLowerCase()
let sorted2 = arr2.sort().join('').toLowerCase()

console.log(sorted1)
console.log(sorted2)

if(sorted1 === sorted2){
console.log(true)
return true
}
else {
console.log(false)
return false
}
}

anagrams('rail safety', 'fairy tales')
anagrams('RAIL! SAFETY!', 'fairy tales')
anagrams('Hi there', 'Bye there')
anagrams('Hi! Whoa!', 'Whoa! Hi!')

module.exports = anagrams;
12 changes: 12 additions & 0 deletions exercises/capitalize/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src=""></script>
</head>
<body>
<h1 style="color: blue;"> Hello</h1>
</body>
</html>
36 changes: 35 additions & 1 deletion exercises/capitalize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,40 @@
// capitalize('a lazy fox') --> 'A Lazy Fox'
// capitalize('look, it is working!') --> 'Look, It Is Working!'

function capitalize(str) {}
function capitalize(str) {
// let arr = []

// let splitString = str.split(" ")
// console.log(splitString)

// splitString.forEach(word => {
// string.push(word[0].toUpperCase() + word.slice(1))
// console.log(word.slice(1))

// });

// return string.join(' ')

let stringResult = str[0][0].toUpperCase()

let splitArr = str.split(' ')

for(let i = 1; i < str.length; i++ ){
if(str[i - 1] === ' '){
stringResult += str[i].toUpperCase()
}
else{
stringResult += str[i]
}
}
console.log(stringResult)
}


capitalize('get the motion tag');
module.exports = capitalize;


Boolean(10<9)

window.open('www.')
1 change: 1 addition & 0 deletions exercises/capitalize/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* hdello */
40 changes: 39 additions & 1 deletion exercises/chunk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,44 @@
// chunk([1, 2, 3, 4, 5], 4) --> [[ 1, 2, 3, 4], [5]]
// chunk([1, 2, 3, 4, 5], 10) --> [[ 1, 2, 3, 4, 5]]

function chunk(array, size) {}
function chunk(array, size) {

// create an array as result

let result = [];
let count = 1;
let subArray = [];

//traverse through array

for(let i = 0; i < array.length; i++) {
//2 % 3 !== 0
if(count % (size + 1) !== 0){ //[5]
subArray.push(array[i])
console.log(subArray)
count++;
console.log(count)
}
else{
result.push(subArray) //[[1,2],[3,4]]
subArray = []
count = 1
subArray.push(array[i])
count++
}
}

result.push(subArray)

return result

//determin the max array based off the size

//insert into the result array

}

chunk([1,2,3,4,5], 2)


module.exports = chunk;
18 changes: 17 additions & 1 deletion exercises/fib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@
// Example:
// fib(4) === 3

function fib(n) {}
function fib(n) {
// let sum = 0, a = 0, b = 1
// for (let i = 2; i <= n; i++) {
// sum = a + b
// a = b
// b = sum
// }

// return b
if(n < 2) {
return n
}

return fib(n-1) + fib(n-2)

}

console.log(fib(6))
module.exports = fib;
22 changes: 21 additions & 1 deletion exercises/fizzbuzz/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,26 @@
// 4
// buzz

function fizzBuzz(n) {}
function fizzBuzz(n) {

for(let i = 1; i <= n; i++ ){

if(i % 3 === 0 && i % 5 === 0){
console.log("fizzbuzz")
}
else if(i % 3 === 0){
console.log("fizz")
}
else if(i % 5 === 0){
console.log("buzz")
}
else{
console.log(i)
}

}
}

fizzBuzz(15)

module.exports = fizzBuzz;
146 changes: 144 additions & 2 deletions exercises/linkedlist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,150 @@
// Implement classes Node and Linked Lists
// See 'directions' document

class Node {}
class Node {
constructor(data, next = null) {
this.data = data
this.next = next
}
}

class LinkedList {}
class LinkedList {
constructor() {
this.head = null
}

insertFirst(record) {
this.head = new Node(record, this.head)

}

size(){
let count = 0;
if(this.head === null){
return count
}
let current = this.head
while(current.next !== null){
current = current.next
count++
}
return count + 1
}

getFirst() {
return this.head
}

getLast() {
let current = this.head
while(current.next){
current = current.next
}
return current
}
clear() {
this.head = null
}

removeFirst() {
this.head = this.head.next
}

removeLast() {
if(!this.head) {
return;
}

if(!this.head.next) {
this.head = null
return;
}

let previous = this.head
let current = this.head.next

while(current.next){
previous = previous.next
current = current.next

}
previous.next = null
}

insertLast(record) {

if(!this.head) {
this.head = new Node(record, this.head)
}

let current = this.head

while(current.next) {
current = current.next
}
current.next = new Node(record)
}

getAt(index) {
if(!this.head) {
return null
}

let current = this.head.next
let counter = 0

while(current) {
if(counter === index) {
return current
}
counter++
current = current.next

}
console.log('ran')
return null
}

removeAt(index){
if(!this.head) {
return null
}

if(index === 0){
return this.removeFirst()
}

let previous = this.getAt(index - 1)
if(!previous || !previous.next){
return null
}

previous.next = previous.next.next
}

insertAt(record, index) {
if(index === 0) {
this.head = new Node(record, this.head)
return;
}

if(!this.head) {
this.head = new Node(record, this.head)
return;
}

let previous = this.getAt(index - 1) || this.getLast()
let current = new Node(record, previous.next)

previous.next = current;
}

forEach(func) {

}



}

module.exports = { Node, LinkedList };
Loading