๐Ÿ˜›TIL 0119

JBยท2022๋…„ 1์›” 19์ผ
0

CodeCamp FE 05

๋ชฉ๋ก ๋ณด๊ธฐ
8/33

[Review]

๐Ÿ—“ Create Date Object

  • getMonth() starts from zero, so to start from January, the user must add 1.
  • getDate() shows days as numbers. 0 is Monday and 6 is Sunday.
  • these get000() is called implicit objects. -- ๋‚ด์žฅ๊ฐ์ฒด--

โฌ‡๏ธ How to import

getMyDate(el.createdAt)
import {getMyDate} from "../../../../commons/libraries/---"
--> myDate only exists inside the (bracket).


โœ‰๏ธ Argument (์ธ์ž)
aaa(3,4)
โœ”๏ธ 3 and 4 are arguments.

๐Ÿ›’ Parameter (๋งค๊ฐœ๋ณ€์ˆ˜)
function add (a,b){ console.log(a+b) }
โœ”๏ธ a+b is a parameter.


[Re-Using Components]

โœ”๏ธ Making one page and importing objects or functions to the other
โœ”๏ธ But if there are two separate pages without any connections, it might be hard to edit both sides to make sure they look the same. Also, it is a wrong way to make two similar pages with separate components.

๐Ÿ“‹ Example Practice - New Page / Edit Page

๐Ÿ”† New page and edit page must be the parent component and use props to edit details.

  • If the user does hard-coding for each pages, he must copy and paste every changes he had done for every single pages, which is annoying.
  • To prevent doing so, the details must be pulled out to other src folders and use them by importing to each pages.

โฌ‡๏ธ New Page

//New Page
import Example from '../../src/components/units/08-example/Example.container'
export default function ExampleNewPage(){
    return(
        <Example aaa={false}/>  
        //just <Example/> is okay if aaa={true} is created in edit page
    )
}

โฌ‡๏ธ Edit Page

import Example from '../../src/components/units/08-example/Example.container.js'

export default function ExampleEditPage(){
    return(
        <Example aaa={true}/> 
    )
}

โฌ‡๏ธ Page Container

import ExampleUI from './Example.presenter'
export default function Example(props){
    return(
        <ExampleUI aaa = {props.aaa}/>
    )
}

โฌ‡๏ธ Page Presenter

export default function ExampleUI(props){
    return(
        <div>
            <h1>{props.aaa ? "edit" : "post"}ํŽ˜์ด์ง€</h1>
            ์ œ๋ชฉ: <input type="text"/><br/>
            ๋‚ด์šฉ: <input type="text"/><br/>
            <button>Do {props.aaa ? "edit" : "post"}</button>
			// if props.aaa=== true, "Do edit" ':'(if not) "Do Post" 
        </div>
    )
}

[Table Tag]

โžก๏ธ Used when there exists numerous addresses in one program.
โžก๏ธ Basically just creating a table
<table>: table tag is like a body tag

  • It should have the tail tag. (</table>)

<th> : (table head) header cell

  • Writes the title of the table
  • Bold font type

<tr> : (table row) standard cell

  • Makes the horizontal line in the table

<td> : (table data) standard cell

  • Creates cells(the data)
  • The contents are written inside the td tag.
  • If the user wants 4 contents, <td/> x4

[Algorithms - isNaN]

โฌ‡๏ธ Finding Kim

function solution(seoul) {
    let x =0;
    for (let i=0; i<seoul.length; i++){
        console.log(i, seoul[i])
        if (seoul[i] ==="Kim"){
            x =i;
        }
    }
    return `๊น€์„œ๋ฐฉ์€ ${x}์— ์žˆ๋‹ค`;
}
  • The user inputs an array containing string formed names, and at this point the computer is finding out which location Kim is.
  • x is a variable for saving the location of Kim
  • Then, I declared i for an index and made a for loop for the userInput seoul's length.
  • The computer returns the index number of Kim.
    So basically the index value goes into the variable x.

โฌ‡๏ธ String True/False

function solution(s) {
    if (s.length === 4 || s.length === 6){
    for (let i= 0; i<s.length;i++){
        if (isNaN(s[i])){
            return false;
        }
        else {
            return true;
        }
    }
    }
}

๐Ÿงฉ isNaN()

  • This function checks whether the input is the number or not.
  • When string is detected, it returns true since NaN stands for Not a Number.
  • So if s[i] is not a number, the system returns false since the system is looking for number, not strings.

โฌ‡๏ธ String True/False

function solution(n) {
    let answer = 0;
    for (let i=0; i<=n; i++){
        if (n%i===0){
            answer += i
        }
    }
    return answer;
}
  • EZ
profile
๋‘๋น„๋‘๋ฐฅ๋ฐฅ

0๊ฐœ์˜ ๋Œ“๊ธ€