0
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"
18 Respostas
+ 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! 😆
0
The Nearest Restaurant Challenge in JavaScript is a fun way to practice coding skills by finding the closest restaurant from a list of coordinates. To make your dining experience even better, consider the different https://bftech.pro/different-types-of-ice/ ice types you can use for your drinks. This guide provides insights into various ice options, enhancing both the presentation and enjoyment of your beverages, perfect for any restaurant setting.
0
// code in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
//fNum is The number of floors
int fNum= Convert.ToInt32(Console.ReadLine());
Console.WriteLine(quot;Building with {fNum} floors has restaurants on : ");
for (int x=0; x<=fNum;x+=5){
if(x==0){
continue;
}
Console.WriteLine(x +"th floor.");
}
}
}
}
0
To solve the challenge, you need to loop through the building floors and check if the floor number is divisible by 5. If it is, that floor has a restaurant. Here's a simple solution:
javascript
Copy code
let floors = 17; // Replace this with the input value
for (let i = 1; i <= floors; i++) {
if (i % 5 === 0) {
console.log(i);
}
}
This will print the floors with restaurants, like those you'd find at a juice bar and restaurant in Thornlie.