Input + Output = True
ํ๋ก๊ทธ๋๋จธ์ค - ์์ธ์์ ๊น์๋ฐฉ ์ฐพ๊ธฐ ๋ณธ๋ฌธ
์์ธ์์ ๊น์๋ฐฉ ์ฐพ๊ธฐ
๋ฌธ์ ์ค๋ช
Stringํ ๋ฐฐ์ด seoul์ element์ค "Kim"์ ์์น x๋ฅผ ์ฐพ์,
"๊น์๋ฐฉ์ x์ ์๋ค"๋ String์ ๋ฐํํ๋ ํจ์, solution์ ์์ฑํ์ธ์.
seoul์ "Kim"์ ์ค์ง ํ ๋ฒ๋ง ๋ํ๋๋ฉฐ ์๋ชป๋ ๊ฐ์ด ์
๋ ฅ๋๋ ๊ฒฝ์ฐ๋ ์์ต๋๋ค.
์ ํ ์ฌํญ
seoul์ ๊ธธ์ด 1 ์ด์, 1000 ์ดํ์ธ ๋ฐฐ์ด์
๋๋ค.
seoul์ ์์๋ ๊ธธ์ด 1 ์ด์, 20 ์ดํ์ธ ๋ฌธ์์ด์
๋๋ค.
"Kim"์ ๋ฐ๋์ seoul ์์ ํฌํจ๋์ด ์์ต๋๋ค.
const seoul = ["Jane", "Kim"]
function solution(seoul){
return `๊น์๋ฐฉ์ ${seoul.indexOf('Kim')}์ ์๋ค`
}
console.log(solution(seoul))
indexOf ํจ์๋ก ๊ฐ๋จํ๊ฒ ๊ตฌํํ๋ค.
https://school.programmers.co.kr/learn/courses/30/lessons/12919?language=javascript
'๐ตAlgorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
ํ๋ก๊ทธ๋๋จธ์ค - ์์ฃผํ์ง ๋ชปํ ์ ์ (0) | 2023.01.11 |
---|---|
ํ๋ก๊ทธ๋๋จธ์ค - ์๋ฐ์๋ฐ์๋ฐ์๋ฐ์๋ฐ์? (0) | 2023.01.08 |
ํ๋ก๊ทธ๋๋จธ์ค - ๋ฌธ์์ด ๋ค๋ฃจ๊ธฐ ๊ธฐ๋ณธ (0) | 2023.01.06 |
ํ๋ก๊ทธ๋๋จธ์ค - ๋ฌธ์์ด ๋ด p์ y์ ๊ฐ์ (0) | 2023.01.04 |
ํ๋ก๊ทธ๋๋จธ์ค - ๋ด์ (0) | 2023.01.03 |
Comments