New course! Every coder should learn Generative AI!
Try a free lesson0
Nearest Restaurant challenge (JavaScript)
Hi everyone, I don't understand how to complete this challenge in the JavaScript introduction, can someone please help me to solve this? (ᗒᗣᗕ)՞ "Nearest Restaurant A group of buildings has a restaurant on every 5th floor. In other words, a building with 12 floors has restaurants on the 5th and 10th floors. The given code takes the number of floors as input. Task Complete the code to output the floors that have restaurants. Sample Input 17 Sample Output 5 10 15"
15 Answers
+ 2
Yume ,
So what do want,ready-made code?
where are your try/attemp?
Note that:
Providing `readymade` code, this feature is not available here.First Try by yourself,after this if you face any problems in during learning or making code then ask here..
Otherhand,
If you're having trouble in code, share your code and describe what error message you're receiving. without watching no one can figure out what's going wrong.
D1M3 ,
don't try to give direct answers..
just give only hints and Let him try himself.
+ 2
Yume ,
If you don't know how to start,
Plz repeat the lesson again and then try.
If any problem arises after that then ask here..
+ 1
D1M3 Tbh, I don't have a single line of code for this challenge, I don't even know where to start, lol! :')
Darpan kesharwani🇮🇳 I'm not asking for a ready-made code but rather for possible solutions/explanations, I really don't understand how to go about this code but I'm tryin' my best. >w<'
0
Use for loops
0
Like:
for(int i = 0;i < floors;i++);
This is c++
0
I already tried, I figured out how to do it with Python but I can't find the solution with JavaScript... ;w;
0
Could you sent me your Code?
0
Darpan kesharwani🇮🇳 Alr did But If He cant solve it him selv
0
Create an var/int Name it Like "floor"
Than create a 'for Loop' Like this :
for(int i = 0;i < floors;i++){
0
Put in a 'if'
Use it an Array and Look If its 0 when you use %5
0
D1M3 Thank you very much for your explanations, I'll try with this, I'll let you know when I have solved it! \o/
Darpan kesharwani🇮🇳 By the way, I've already tried but if I'm asking for advice here, maybe it's because I can't find the solution on my own, don't you think so? ^^'
0
Wong Hei Ming I just solved it, thanks again to D1M3 for his explanations, I finally understood everything! ( ˙꒳˙ )
0
let floors = 20;
for (let x=0; x<=floors; x+=5){
if(x==0){
continue;
}
console.log(x);
}
0
Ahmed Abd El-Awal That's exactly what I did in the end but thanks, now I know I could hardly have done better! 😆