Speed of Sound | SoloLearn: Learn to code for FREE!

+10

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 }

11/21/2020 8:01:11 PM

Andrew Medrano

40 Answers

New Answer

+20

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.

+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. 😉👌

+11

Where is your attempted code? Post it here..

+8

Look in functions Andrew Medrano https://www.sololearn.com/learn/JavaScript/1149/

+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.

+6

Andrew Medrano, You are going to be seriously disappointed if you are expecting to be spoon fed every function available in Python by SoloLearn. In the lessons on Pip and the standard library it actually states... "We won't cover all of the modules in the standard library; there are simply too many. The complete documentation for the standard library is available online at www.python.org." You are expected to do some reading yourself. See... https://docs.python.org/3/ I don't know where this prompt() function is coming from though. It isn't a built in function. The prototype for the input function is.. input([prompt]) the prompt parameter is optional. https://docs.python.org/3/library/functions.html#input

+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.

+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'.

+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

+4

var seconds = prompt();

+4

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..

+4

Martin Taylor he has tagged JavaScript not python https://code.sololearn.com/W2KNy33uuaT9/?ref=app

+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🤔🤔🤔

+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?

+3

Martin Taylor the problem was in JavaScript, but anyway the essence of what you said applies in general to leaning a language

+3

Andrew Medrano, My sincere apologies for the Python link. For some reason the "prompt" stuck in my mind from the input([prompt]) syntax from Python. That and the fact that standard JavaScript does not contain any methods for accepting user input from the command line. However, you will find it is the case with the majority of the languages covered here on SoloLearn that the standard libraries are not covered in detail. The C standard library is quite small but C++ is considerably larger. Java contains over 5,000 classes and the Python Package Index (PyPi) contains 273,506 projects. Node.js uses the Node Package manager (npm), I have no idea how many packages are publicly available for node.js but you can be certain it is more than a few hundred. For an example of using prompt() see... https://www.codecademy.com/articles/getting-user-input-in-node-js https://github.com/heapwolf/prompt-sync

+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

+3

David Carroll Thanks for important lesson its not just its teach us as well 🙏

+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

+2

they never taught us prompt () in the lessons prior. i just need to be able to solve test case #2 and #3.