Java script basic algorithm challenges


#1

Hi I am doing the basic algorithm challenges for javascript and I am trying out the code in code pen. It doesn’t work is there. Is there a template that has some html and css and a space to put your javascript code to test it out. Or even a better way to play around with the code?


#2

I suggest you start using your own text editor and have your own setup to get the hang of it. This is what I do using atom:

<!DOCTYPE>
<html>
<head>
<meta charset="UTF-8"/>
<title>Algorithm Challenges</title>
</head>

<body>

<script>
// Algorithm Challenge here:
function foo(){
 return 'Hello world';
}
console.log(foo());
</script>

</body>
</html>

And open your file in your browser. Hope this helps :slight_smile:


#3

Chrome devtools snippets is far and away the best way to run just javascript code

https://developers.google.com/web/tools/chrome-devtools/snippets

Other great options are run code under node or vscode

https://nodejs.org/dist/latest-v8.x/docs/api/repl.html

https://code.visualstudio.com/


#4

With no intention to offend even with the extra big words:

Why? Just why in the world? Of all the places you can test algorithms…

I recommend you:


Or if you have Sublime, Atom or VSCode you can install a plugin/package that executes a JS file with NodeJS. For atom there’s Script! (or Run, I don’t remember), for Sublime there’s integrated builds and for VSCode there’s CodeRunner.


#5

I second the Repl.it:

https://repl.it

It’s a great platform to test your JavaScript!


#6

I third Repl.it… It’s pretty awesome. But…I just installed sublime text a couple days ago and you reminded me to try and see about how to test my code in there… took me all of 5 minutes to set it up :smiley:


#7

I agree with using repl.it, though you can use codepen without html and css. console.log will output to the dev console - I’ve done this several times, but repl.it is the better environment for pure javascript.


#8

Hi All, I apologizer for the delay in getting back to you. I just wanted to say thankyou I ended up using visual studio code and sublime. The text editors work great and I appreciate your suggestions