| Method | Path | Purpose |
|---|---|---|
| GET | / | Home page |
| GET | /places | Places index page |
| POST | /places | Create new place |
| GET | /places/new | Form page for creating a new place |
| GET | /places/:id | Details about a particular place |
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
| def flip(string): | |
| print(string[::-1]) | |
| flip("A man, a plan, a canal: Panama") |
Activity: Array Iterator Practice 5 Trophy Games is looking to boost their user profile pages and add some perks for different users. The marketing team prefers to have some simple lists of user data requested, and it's your job to get that data to them.
In this activity, we will use the iterators .forEach, .map, and .filter to solve a variety of array-centric challenges.
For each challenge, you will need to determine the best iterator for the job.
For each of the following exercises, use this array as an example of what users could be.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 React = require("react"); | |
| const Default = require("./layouts/Default"); | |
| function New() { | |
| return ( | |
| <Default> | |
| <h2>Add a new bread</h2> | |
| <form action="/breads" method="POST"> | |
| <label htmlFor="name">Name</label> | |
| <input type="text" name="name" id="name" required /> |
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
| apt update && \ | |
| apt install -y wget && \ | |
| DEBIAN_FRONTEND=noninteractive apt-get install openssh-server -y && \ | |
| mkdir -p ~/.ssh && \ | |
| cd $_ && \ | |
| chmod 700 ~/.ssh && \ | |
| echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII2AOiMJXSWr/yYuAkSur/QSfdwBbmK3hs4qzlMvOQxT dmml@Dmms-MBP" >> authorized_keys && \ | |
| service ssh start |
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
| var readline = require('readline'); | |
| readline.emitKeypressEvents(process.stdin); | |
| if (process.stdin.isTTY) | |
| process.stdin.setRawMode(true); | |
| process.stdin.on('keypress', (chunk, key) => { | |
| if (key && key.name == 'q') | |
| process.exit(); |
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 compress = (str) => { | |
| let result = [] | |
| let i = 0; | |
| let j = 0; | |
| while(j <= str.length){ | |
| if(str[i]===str[j]){ | |
| j+=1 | |
| }else{ | |
| const num = j-i | |
| if(num===1){ |
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 compress = (s) => { | |
| let result=[] | |
| const strArr = s.split('') | |
| const strMap = strArr.reduce((acc,param)=>{ | |
| if(!acc[param]){ | |
| acc[param]=1 | |
| return acc | |
| } | |
| acc[param]++ | |
| return acc |