今日已更新 412 条资讯 | 累计 19972 条内容
关于我们

标签:#apnacollege

找到 2 篇相关文章

AI 资讯

Day 31 of learning MERN Stack

Hello Dev Community! 👋 It is officially Day 31 — stepping straight into my second month of documented full-stack engineering! Fresh off the 30-day milestone yesterday, I decided to keep the engineering momentum high by building a classic browser game: Rock, Paper, Scissors using HTML5, CSS3, and vanilla JavaScript. After mastering API integration yesterday, today was about refinement—handling dynamic score states, tracking user choices, and creating a clean automated opponent engine. 🛠️ The Core Logic Architecture To make the game interactive and clean, I divided the code structure into distinct logical components: 1. Capturing User Selection I assigned the choices (rock, paper, scissors) to clickable image/div nodes in the layout. Instead of writing repetitive lines, I used a forEach array loop to attach an addEventListener("click", ...) to each choice, pulling the user's explicit selection instantly via DOM attributes. 2. The Computer's Automated AI Brain Since a computer cannot pick words, I mapped out an array of strings: ["rock", "paper", "scissors"] . I then utilized JavaScript's math utility library to generate a randomized index number: javascript const genCompChoice = () => { const options = ["rock", "paper", "scissors"]; const randIdx = Math.floor(Math.random() * 3); return options[randIdx]; };

2026-06-15 原文 →
开发者

Day 26 of Learning MERN Stack

Hello Dev Community! 👋 It is officially Day 26 of my journey to master the MERN stack! Today, I continued with Lecture 9 of Apna College's JavaScript playlist with Shradha Didi, transitioning from raw prototype object manipulation into modern ES6 structural design: Classes and Inheritance . Yesterday we saw how single objects share methods; today I learned how to create scalable blueprints to manufacture objects efficiently. 🧠 Key Learnings From JS Lecture 9 (Classes & OOP) I explored the professional layout of Object-Oriented Programming (OOP) in modern JavaScript: 1. What is a Class and a Constructor? A class is a standardized blueprint for creating objects. Inside every class, we can define a special method called a constructor() . The constructor triggers automatically the exact moment a new object is instantiated using the new keyword. It is the standard place to initialize instance properties dynamically. javascript class Car { constructor(brand, hp) { this.brandName = brand; this.horsepower = hp; } } let myCar = new Car("Toyota", 180); // Instantiates a fresh object instantly

2026-06-14 原文 →