Silver Library (Archived)
[JS] Day 1 : let and const 본문
hackerrank, 10days of JS.
Title: Day 1: let and const
Personal note: This is for the record to see how I figured out the algorithm.
- parseFloat is the print like feature in float. Literally, parsing its data to float.
- r = parseFloat(readLine());
- this readLine indicates 'I wish to read only a single line for each.'
- as problem asked, declare PI to const.
- const PI = Math.PI;
CAUTION: Don't put Math.PI(); because PI got nothing to receive and print out at this point.
In this case, Math is the one to do that role.
Afterwards, print each of them accordingly.
- console.log(PI * r * r); // this is area formula (for circle)
- console.log(PI * 2 * r); // this is perimeter formula
Let's think about this in this way.
1. define r value.
2. define how to print r value.
3. use parseFloat. and wrap up the readLine.
4. readLine has bracket (). Now he is ready to read out anything that receives (that fits).
5. declare const PI as instruction stated.
6. MUST USE Math.PI; Math is a method & JS's inner property. Do not manipulate this.
I know this time's opportunity is too sudden...but I have to try.
'F2. Problem & Solving > Solving' 카테고리의 다른 글
Conditional statements: switch (0) | 2021.06.12 |
---|---|
Conditional statement: if-else (0) | 2021.06.12 |
Plan of learning the algorithm (0) | 2021.05.01 |
Baekjoon algorithm - 10430 , python (map) (0) | 2021.02.15 |
baekjoon algorithm - 10869 (0) | 2021.02.15 |