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 vetApprovedDogs = [ | |
| {name: 'Snookums', needsShots: false, breed: 'pug', age: 2}, | |
| {name: 'Thor', needsShots: false, breed: 'hound', age: 1}, | |
| {name: 'Wunderbar', needsShots: false, breed: 'pug', age: 9}, | |
| ] | |
| // I need a little more practice with map! | |
| const allDogsAges = vetApprovedDogs.map(dog => dog.age) | |
| console.log(allDogsAges) // [2, 1, 9] |
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 vetApprovedDogs = [ | |
| {name: 'Snookums', needsShots: false, breed: 'pug', age: 2}, | |
| {name: 'Thor', needsShots: false, breed: 'hound', age: 1}, | |
| {name: 'Wunderbar', needsShots: false, breed: 'pug', age: 9}, | |
| ] | |
| // The big report for the city, have to be sure we get this right! | |
| const reportForCity = vetApprovedDogs.myReduce((report, dog) => { | |
| // Is this breed not in the report? |
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 nums = [2, 6, 3, 10] | |
| const nums2 = [2, 4, 1, 2] | |
| const duplicates = arr => { | |
| for (let i = 0; i < arr.length; i++) { | |
| for (let j = 0; j < arr.length; j++) { | |
| // If the indexes do not match but the | |
| // values do, we have a duplicate! |
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 nums = [2, 6, 3, 10] | |
| const nums2 = [2, 4, 1, 2] | |
| const duplicates2 = arr => { | |
| for (let i = 0; i < arr.length; i++) { | |
| // Cut down on our work by not considering pairs | |
| // we have already looked at | |
| for (let j = i + 1; j < arr.length; j++) { |
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 nums = [2, 6, 3, 10] | |
| const nums2 = [2, 4, 1, 2] | |
| const duplicates3 = arr => { | |
| for (let i = 0; i < arr.length; i++) { | |
| const num = arr[i] | |
| // We take a slice of the remaining Array | |
| // and see if that includes the num | |
| // it must be a duplicate |
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 nums = [2, 6, 3, 10] | |
| const nums2 = [2, 4, 1, 2] | |
| const duplicates4 = arr => { | |
| // Start with an empty Object as a | |
| // record keeper | |
| const obj = {} | |
| for (let i = 0; i < arr.length; i++) { |
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 nums = [] | |
| for (let i = 0; i <= 10000; i++) { | |
| nums.push(i) | |
| } | |
| const nums2 = [...nums, 10000] | |
| // previously written functions for duplicates | |
| // duplicates2, duplicates3, duplicates4 |
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, { Component } from 'react' | |
| import Spinner from './Spinner' | |
| import Images from './Images' | |
| import Buttons from './Buttons' | |
| import { API_URL } from './config' | |
| import './App.css' | |
| export default class App extends Component { | |
| state = { |
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
| require('dotenv').config() | |
| const express = require('express') | |
| const cloudinary = require('cloudinary') | |
| const formData = require('express-form-data') | |
| const cors = require('cors') | |
| const { CLIENT_ORIGIN } = require('./config') | |
| const app = express() | |
| cloudinary.config({ |
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 { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | |
| import { faBowlingBall } from '@fortawesome/free-solid-svg-icons' | |
| export default () => | |
| <div className='spinner fadein'> | |
| <FontAwesomeIcon icon={faBowlingBall} size='5x' color='#3B5998' /> | |
| </div> |