Comments (4)
No, it should always display 10 numbers.
from thejsway.
@bpesquet Sorry, I cannot understand. If a user sets the initial number as 9
, how this program can output 10
odd/even numbers between 9
and 10
?
from thejsway.
OK, the sentence is hopefully more clear now.
from thejsway.
@bpesquet
This is the second possible variant:
for (let i = 1; i <= 10; i++) {
if (i % 2 === 0) {
console.log(`${i} is even`);
} else {
console.log(`${i} is odd`);
}
}
output:
1 is odd
2 is even
3 is odd
4 is even
5 is odd
6 is even
7 is odd
8 is even
9 is odd
10 is even
This is the third possible variant with a user input:
for (let i = Number(prompt("Type the initial number:")); i <= 10; i++) {
if (i % 2 === 0) {
console.log(`${i} is even`);
} else {
console.log(`${i} is odd`);
}
}
Output if a user types 9
:
9 is odd
10 is even
As you can see, the last program cannot always show exactly 10 numbers.
from thejsway.
Related Issues (20)
- chapter14.md: "wonders" should be "exists".
- chapter 22 > weather HOT 3
- translation into Chinese HOT 1
- Translation in french HOT 1
- Contributing Additional Exercises HOT 2
- Jsvay HOT 1
- Chapter 14 ->link broken HOT 1
- Chapter 14 -> missing word HOT 1
- broken link / Chapter 17 HOT 1
- Syntax error in Character class example/Chapter 9
- Wrong word Chapter 18
- function instead of functions -> Chapter 18 HOT 1
- leave vs let -> Chapter 18 HOT 1
- broken link chapter 19
- Chapter 06 - arrays named "values" HOT 2
- Upper case letter missing -> chapter 20 HOT 1
- Chapter 20 tinyIssues HOT 1
- The JavaScript Way Translation in Persian HOT 12
- Translate to brazilian portuguese HOT 2
- How to build an ai simulation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thejsway.