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"

10th Oct 2023, 11:49 AM
Yume
Yume - avatar
18 Antworten
+ 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.
10th Oct 2023, 11:59 AM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 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..
10th Oct 2023, 12:19 PM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 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<'
10th Oct 2023, 12:07 PM
Yume
Yume - avatar
+ 1
Yume, you said you do have a working code in Python, didn't you? Why not show your code in Python, then we can examine it and help you to translate into JavaScript?
10th Oct 2023, 1:10 PM
Wong Hei Ming
Wong Hei Ming - avatar
0
Use for loops
10th Oct 2023, 11:51 AM
D1M3
D1M3 - avatar
0
Like: for(int i = 0;i < floors;i++); This is c++
10th Oct 2023, 11:51 AM
D1M3
D1M3 - avatar
0
I already tried, I figured out how to do it with Python but I can't find the solution with JavaScript... ;w;
10th Oct 2023, 11:56 AM
Yume
Yume - avatar
0
Could you sent me your Code?
10th Oct 2023, 11:57 AM
D1M3
D1M3 - avatar
0
Darpan kesharwani🇮🇳 Alr did But If He cant solve it him selv
10th Oct 2023, 12:02 PM
D1M3
D1M3 - avatar
0
Create an var/int Name it Like "floor" Than create a 'for Loop' Like this : for(int i = 0;i < floors;i++){
10th Oct 2023, 12:11 PM
D1M3
D1M3 - avatar
0
Put in a 'if' Use it an Array and Look If its 0 when you use %5
10th Oct 2023, 12:13 PM
D1M3
D1M3 - avatar
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? ^^'
10th Oct 2023, 12:33 PM
Yume
Yume - avatar
0
Wong Hei Ming I just solved it, thanks again to D1M3 for his explanations, I finally understood everything! ( ˙꒳˙ )
10th Oct 2023, 1:49 PM
Yume
Yume - avatar
0
let floors = 20; for (let x=0; x<=floors; x+=5){ if(x==0){ continue; } console.log(x); }
10th Nov 2023, 4:00 AM
Ahmed Abd El-Awal
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! 😆
15th Nov 2023, 9:20 PM
Yume
Yume - avatar
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.
6th Aug 2024, 7:07 AM
Jony Claber
Jony Claber - avatar
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."); } } } }
21st Aug 2024, 10:52 AM
Asmaa El-Deeb
Asmaa El-Deeb - avatar
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.
22nd Aug 2024, 8:02 AM
freshpoint
freshpoint - avatar