0

Print character of odd position given a string using JavaScript?

in JavaScript

2nd Feb 2018, 2:51 AM
Hemang Parmar
Hemang Parmar - avatar
4 Answers
+ 2
explain?
4th Feb 2018, 7:05 PM
Chat d'Oeuf (Baron)
Chat d'Oeuf (Baron) - avatar
+ 1
ooh i get it! also that is c++ and not js but the code is simple! var chars = "123456789"; for(i=0;i<chars.length;i++) { if(parseInt(chars[i])%2!==0) { console.log(parseInt(chars[i])); } }
5th Feb 2018, 6:56 AM
Chat d'Oeuf (Baron)
Chat d'Oeuf (Baron) - avatar
0
using js.! not c++? plz explain
31st Jul 2018, 5:01 PM
Hemang Parmar
Hemang Parmar - avatar
- 1
str = "0123456" for(var I = 0; I < str.length; I++){ if(I%2!=0){ //check if odd using modulus cout<<I<<" = "<<str[I]<<endl; } } output: 1 3 5
4th Feb 2018, 8:11 PM
Michael Simnitt
Michael Simnitt - avatar