JavaScript Coding Challenge - 2
/*
Question - Write a program to print A sting in separate letters..
For Eample..
BANANA --> B A N A N A
INDIA --> I N D I A
*/
------------------------------------------------------------------------------------
/* Solution-1 */
const iterable = 'banana';
for (const value of iterable) {
console.log(value);
}
/*
Solution - 2
*/
const iterable = new Set([1, 1, 2, 2, 3, 3]);
for (const value of iterable) {
console.log(value);
}
Comments
Post a Comment