This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here's another solution I made previously using some fancy reduce stuff to make me look cool | |
// https://www.codewars.com/kata/576bb71bbbcf0951d5000044/train/javascript | |
function countPositivesSumNegatives(input) { | |
if(!input || input.length === 0) return []; | |
return input.reduce( | |
(result, num) => (num > 0) ? [++result[0], result[1]] : [result[0], result[1] + num], | |
[0, 0] | |
) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Racing | |
function startRiggedRace(riggedWinner, riggedLoser) { | |
var racers = [riggedWinner]; | |
// Other ways we could add the rigged Winner | |
//racers.splice(0, 0, riggedWinner); | |
//racers.unshift(riggedWinner); | |
//racers.push(riggedWinner); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { PropTypes } from 'prop-types'; | |
import { useSelector } from 'react-redux'; | |
/** | |
* Shows a category name and the number of transactions in that category | |
* Expects to go inside a <ul> with the class "list-group" | |
* | |
* @component | |
* @example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 0; | |
background-color: #fafafa; | |
font-family: Verdana, Geneva, Tahoma, sans-serif; | |
} | |
.button { | |
border: 0; | |
padding: 15px; | |
background-color: lightgray; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.codewars.com/kata/59de469cfc3c492da80000c5/train/javascript | |
function compress(sentence) { | |
// Get all the words lower case in an array | |
const words = sentence.split(" ").map(word => word.toLowerCase()); | |
// Get rid of all the duplicates | |
const uniqueWords = words.filter( (word, index) => words.indexOf(word) === index ); | |
// Make a string of the position of each word in the non-duplicates array | |
return words.map(word => uniqueWords.indexOf(word)).join(""); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
export default function CategoryFilter() { | |
return ( | |
<div style={{ border: "1px solid black", padding: "15px", margin: "15px" }}> | |
<h3>CategoryFilter Component</h3> | |
<button>Tell TransactionFilters I'm Set</button> | |
<button>Tell TransactionFilters I'm Cleared</button> | |
</div> | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const emailList = [ | |
{ | |
id: 234, | |
author: { | |
firstName: "Natalie", | |
lastName: "Childs" | |
}, | |
to: "Calvin", | |
message: "Heyyyy", | |
read: false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.bg-slate { | |
background-color: #4F5D61; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://www.codewars.com/kata/515bb423de843ea99400000a/train/javascript | |
// The constructor takes in an array of items and a integer indicating how many | |
// items fit within a single page | |
class PaginationHelper { | |
constructor(collection, itemsPerPage) { | |
this.collection = collection; | |
this.itemsPerPage = itemsPerPage; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AcceptedAnswerPrompt { | |
constructor(acceptedAnswers) { | |
this.acceptedAnswers = acceptedAnswers; | |
} | |
// Returns true or false depending on if it's in the list or not | |
isAcceptedAnswer(potentialAnswer) { | |
return this.acceptedAnswers.includes(potentialAnswer); | |
} |