π
Get Type
Get Typeμ
λ¬Έ κΈ°μ΄ λ¬Έλ² +5pts
Problem
Write a function that returns the type of the given value.
Examples
Input:
getType(42)Output:
"number"Input:
getType("hello")Output:
"string"Explanation
μ΄ λ¬Έμ λ **typeof μ°μ°μ**λ₯Ό μ¬μ©νμ¬ JavaScriptμ λ°μ΄ν° νμ μ νμΈνλ λ°©λ²μ νμ΅ν©λλ€. **typeof μ°μ°μ** κ°μ νμ μ λ¬Έμμ΄λ‘ λ°νν©λλ€: - typeof 42 β "number" - typeof "hello" β "string" - typeof true β "boolean" **JavaScriptμ κΈ°λ³Έ νμ ** - `"number"`: μ«μ (μ μ, μμ, NaN, Infinity) - `"string"`: λ¬Έμμ΄ - `"boolean"`: true λλ false - `"undefined"...
View detailed explanation βKey Concepts
typeof μ°μ°μ JavaScript λ°μ΄ν° νμ
λμ νμ΄ν νμ
νμΈ
Time: O(1) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.