Skip to main content
r/learnjavascript icon

r/learnjavascript

members
online

JavaScript Day 1: Is this the correct way to capitalize user input? JavaScript Day 1: Is this the correct way to capitalize user input?

Hi everyone 👋
I started learning JavaScript today and practiced string methods like slice(), length, toUpperCase(), toLowerCase(), and concatenation.

I wrote this small snippet to take user input and convert the first character to uppercase while keeping the rest lowercase.

Here’s the code:

var name = prompt("What is your name?");
var sliceresult = name.slice(0, 1);
var ni = sliceresult.toUpperCase();
var low = name.slice(1, name.length);
var nn = low.toLowerCase();

alert("Hello " + ni + nn + "!");

Question :

  1. Is this logic correct for basic name capitalization?

  2. Are there cleaner or more idiomatic ways to do this in JavaScript?

  3. Anything I should avoid or improve as a beginner?

Thanks!


Are JavaScript arrays just objects? Are JavaScript arrays just objects?

Am I misunderstanding something, or is this basically how JavaScript arrays work? From what I can tell, JavaScript arrays are essentially just objects under the hood. The main difference is that they use [] as their literal syntax instead of {}, their keys look like numbers even though they’re actually strings internally, and they come with extra built-in behavior layered on top, like the length property and array-specific methods, which makes them behave more like lists than plain objects.


I built a JS Execution Visualizer to help understand closures, call stack, and async code I built a JS Execution Visualizer to help understand closures, call stack, and async code

I’ve been building a tool called JS Execution Visualizer to help developers see how JavaScript really runs under the hood. Sometimes it’s tricky to understand closures, the call stack, heap memory, or async code like Promises and async/await. This tool lets you watch your JS code execute step by step, with clear visualizations and explanations. 🔹 Features Visual Call Stack & function execution Heap Memory & object references Scope & Closures tracking Step-by-step execution timeline with explanations Try it out here: 🔗 https://js-runtime-visualizer.vercel.app It’s not open-source yet — I want to gather feedback first to make it better. If you try it, I’d love to hear your thoughts! Would love to hear your feedback or ideas for improvements — especially if you’re learning JS or prepping for interviews.