+ 9

Speed of Sound

Please don’t give me a life lesson, if you know how to write the code please share! I’m so lost and irritated I just want to see how it’s done correctly and work backwards. Please! Yes I’ve payed very close attention to the previous lessons but I promise if you were starting from nothing like I am it wouldn’t make sense, they made this problem too difficult early on. The speed of sound in air is 343 meters per second. Create a program that takes the seconds as input, calculates and outputs to the console the distance the sound covers in a given number of seconds. Sample Input 3 Sample Output 1029 The total distance that sound covers in 3 seconds is 3*343 = 1029. Use console.log() to perform an output to the console. //not to overwhelm you we’ve hidden the code that executes the input ;) function main() { var seconds = parseInt(readLine(), 10) // Your code here }

21st Nov 2020, 8:01 PM
Andrew Medrano
Andrew Medrano - avatar
38 Respuestas
+ 19
Andrew Medrano please show us your attempt as this is a very easy exercise. This is a code coach solutions code which is to test your knowledge not that of the community at large. The community may give you guidance but should not give you the exact way to construct the code. Thanks and happy coding.
21st Nov 2020, 8:25 PM
BroFar
BroFar - avatar
+ 14
[Part 2 of 2] In the meantime, try not to get frustrated. Just trust it will all come together if you give it time and discover the pattern for learning. That might require you to look deeper at the specific issues you're struggling with and ask explicit questions or focus your research. Also... realize that the lessons may be trying to strike a balance between enough instructions to get someone started and spending too much time on concepts that may be too basic for many people. The steepest part of this learning curve is training your mind to think logically and explicitly imperative. You'll want to research imperative programming. It's not something many people talk about. But I've been doing this long enough to see most begin to accelerate their learning once they break through this mental rewiring... so to speak. Apologies for breaking your first request, which was: "Please don't give me a life lesson..." But I hope this advice helps clear the path for your mind to figure this out. 😉👌
22nd Nov 2020, 2:27 AM
David Carroll
David Carroll - avatar
+ 11
Where is your attempted code? Post it here..
21st Nov 2020, 8:25 PM
Jayakrishna 🇮🇳
21st Nov 2020, 8:41 PM
BroFar
BroFar - avatar
+ 7
[Part 1 of 2] Hi Andrew Medrano... I suspect most people in your situation think they are only learning Javascript. But, in reality, you're learning so much more with your first programming language. In this case, beyond the core Javascript language and syntax, you're also learning the following as well: - NodeJS runtime environment that extend beyond the core language. - Imperative programming concepts that apply to many other languages. - Variable scope and state as well as the control and flow of logic. - Test Driven Development concepts. - Algorithms and data structures. I imagine this is what makes learning to program so challenging for many beginners. Hopefully, if you're aware of the various moving parts involved you'll be able to isolate the areas you're struggling with and break them down into bite size challenges to overcome. Before you know it, you'll begin to develop an intuition for the unknown bits that may not be relevant to the immediate lesson.
22nd Nov 2020, 2:27 AM
David Carroll
David Carroll - avatar
+ 6
Andrew Medrano I wanted to make sure you saw my earlier posts. Also... you might find the Javascript lessons on FreeCodeCamp.org to be better. Everyone has different learning styles. TBH... I couldn't say which is better at teaching Javascript since I've been working with Javascript since it was first released. But I have heard positive feedback about the approach taken by FreeCodeCamp.org and from my own review, it does look very good for beginners. It would also be a good idea to come back here and test your familiarity or reinforce the concepts using different lesson material. FreeCodeCamp.org might be a good place to start since everything they teach is very hands on. Here's a link to the first lesson in Javascript: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/comment-your-javascript-code Hope this helps.
22nd Nov 2020, 6:20 PM
David Carroll
David Carroll - avatar
+ 5
It's not taught that's why it is given by them only.. You only asked to logic to solve the remaining problem... That's about reading a line and parsing it into a base 10 number.. And code playground there using is node.js I think.. That's why.. Edit : Andrew Medrano prompt also works but convert to number like var seconds = Number( prompt()) But am not sure in 'code coach'.
21st Nov 2020, 8:46 PM
Jayakrishna 🇮🇳
+ 5
These may help you to how it can be solved i think.. Look at once similar ones: You're welcome.. https://www.sololearn.com/Discuss/2563580/?ref=app https://www.sololearn.com/Discuss/2565125/?ref=app
21st Nov 2020, 9:01 PM
Jayakrishna 🇮🇳
+ 5
It is working or not...? Non-pro's can't see pro questions. And solution is private only, non can see... I think prompt not work in code coach.. So there already given taking input statement by readLine method.. I think there it needs only a single statement to add is console.log(seconds*343); If it not works then it's a bug or matter where is adding..
21st Nov 2020, 9:29 PM
Jayakrishna 🇮🇳
+ 4
var seconds = prompt();
21st Nov 2020, 8:35 PM
BroFar
BroFar - avatar
22nd Nov 2020, 1:40 AM
BroFar
BroFar - avatar
+ 3
Andrew Medrano I said "am I" to say "are we all". In your question you haven't mentioned parselime(), probably because it's written in the code that you don't need to care about it. You asked for how to solve the problem and since the solution is explicitly written in the text of the problem and you look smart enough to get it, I just thought you were making fun of us. Input: 3 Output: 3 * 343🤔🤔🤔
21st Nov 2020, 9:03 PM
Davide
Davide - avatar
+ 3
Andrew Medrano I am giving you the benefit of the doubt. So in the code you already got the input stored in the variable "seconds" The text of the problem says you have to output the input multiplied for 343. It also says you to use console.log() to perform an output What about putting the things together?
21st Nov 2020, 9:32 PM
Davide
Davide - avatar
+ 3
Martin Taylor the problem was in JavaScript, but anyway the essence of what you said applies in general to leaning a language
22nd Nov 2020, 12:02 AM
Davide
Davide - avatar
+ 3
Liason Ngayan please create a question explaining your problem, posting your attemp amd tagging a language https://www.sololearn.com/discuss/1316935/?ref=app
23rd Nov 2020, 2:02 AM
Davide
Davide - avatar
+ 3
David Carroll Thanks for important lesson its not just its teach us as well 🙏
23rd Nov 2020, 6:21 AM
Sayyam Jain
Sayyam Jain - avatar
+ 2
var seconds = 3 var speed = 343 var SOS = seconds * speed console.log (SOS) that solves the first portion but will not let me use move on the next portion
21st Nov 2020, 8:31 PM
Andrew Medrano
Andrew Medrano - avatar
+ 2
they never taught us prompt () in the lessons prior. i just need to be able to solve test case #2 and #3.
21st Nov 2020, 8:36 PM
Andrew Medrano
Andrew Medrano - avatar
+ 2
Andrew Medrano am I a joke to you? 😑😑😑
21st Nov 2020, 8:39 PM
Davide
Davide - avatar
+ 2
There already given var seconds = parseInt(readLine(), 10)
21st Nov 2020, 8:40 PM
Jayakrishna 🇮🇳