영상
문제
<script>
/*
[문제]
문자열 hello를 olleh로 출력하시오.
[정답]
olleh
*/
let text = "hello";
</script>
Java
복사
해설
<script>
/*
[문제]
문자열 hello를 olleh로 출력하시오.
[정답]
olleh
*/
let text = "hello";
let index = text.length - 1;
for(let i=0; i<text.length; i++) {
document.write(text[index]);
index -= 1;
}
document.write("<br>");
for(let i=text.length - 1; i>=0; i--) {
document.write(text[i]);
}
</script>
Java
복사