Print odd numbers

Write a function to print odd numbers from 0 to given limit using JavaScript

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

I tried doing this but it’s giving me syntax error.

function odd(n)
  for(i = 0, i <= N, i++){ 
    if(i % 2 != 0){

@vinaykanth-edu, your logic is correct but you have a few syntax errors. Run your code through this;

Note that, like all programming languages, JS is case-sensitive. “N” is not the same as “n”, it’s a completely different character.

And as @Roma says, you have another syntax error: look at an example of how you write a function, you are missing the brackets.

1 Like

Except Fortran. Because Fortran is terrible.


And don’t forget Pascal.

1 Like

Fortran is full of sadness. Powerful numerical capabilities trapped with trash syntax conventions.

Thank you, I was using comma instead of semicolon in the for loop.

Hahaha, no way. I knew there’d be few when I typed the words, I was just too lazy to check


:grimacing: The book description is summat else. I mean it is probably super useful if you are in a position where you gotta use Fortran but…

Edit: haha I hadn’t really.clocked the quote until I posted that. Surely that means he would have spent more time writing his calculations if he’d had the book?? (I assume it’s second language, but the editors could have corrected him, jeez)

You forgot about BASIC (for most dialects I believe). My first programming language on my Amstrad 464. So much fun when you can’t save the program you spend half a day typing out from a book (well I never figure out how to save it anyway).