Given a Pond (array of Fishes) where the Fish object is as below:
// Fish
{
name: string,
size: 'small'|'medium'|'large'
hungry: boolean
}
const pond = [| let count; | |
| if(count==1 && count==2 && count== 3) { | |
| console.log('You did a miracle!"); | |
| } else { | |
| console.log('try again'); | |
| } |
| https://screenshots.codesandbox.io/5xdnb/34.png |
Given a Pond (array of Fishes) where the Fish object is as below:
// Fish
{
name: string,
size: 'small'|'medium'|'large'
hungry: boolean
}
const pond = [- Add an input control (input/textarea) to allow entering text.
- On text change, a food emoji should be rendered for each WORD in the text.
- If the word length is ODD, print a PIZZA emoji 🍕
- If the word length is EVEN, print a BURGER emoji 🍔
- Each emoji should be separated by a <space>.
Example
input : I love Pizza and Burger
| /* HTML */ | |
| <div class="container"> | |
| <div class="tile">1</div> | |
| <div class="tile">2</div> | |
| <div class="tile">3</div> | |
| <div class="tile">4</div> | |
| </div> | |
| /* CSS */ | |
| .container { |
| function f (input, sum = 0) { | |
| if(!input) { | |
| return sum; | |
| } | |
| else { | |
| return function(nextInput) { | |
| sum += input; | |
| return f(nextInput, sum); | |
| } | |
| } |
| /* | |
| H ~~~~ -> | |
| A -> B -> | |
| C -> D | |
| H: high priority long task, should start in parallel to A | |
| A: first task | |
| B: should start once A is finished | |
| C: should start once B & H is finished | |
| D: should start once C is finished |
| _flatten = input => | |
| input.reduce((acc, curr) => | |
| Array.isArray(curr) ? [...acc, ..._flatten(curr)] : [...acc, curr], []); | |
| // test | |
| _flatten([[1,2],3,4,[5,[6,7],8],[9,[10,[11]]]]); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] |
| var chunkedUrl = 'https://jigsaw.w3.org/HTTP/ChunkedScript'; | |
| fetch(chunkedUrl) | |
| .then(processChunkedResponse) | |
| .then(onChunkedResponseComplete) | |
| .catch(onChunkedResponseError) | |
| ; | |
| function onChunkedResponseComplete(result) { | |
| console.log('-----------all done!----------'); | |
| console.log(result); |