• Nov 21, 2023 •AustinLeath
0 likes • 25 views
// Print Hello, World! console.log("Hello, World!");
• Mar 31, 2023 •Helper
0 likes • 5 views
const langToConfig = { 'javascript': { image: '', cmd: [''] }, 'php': { image: '', cmd: [''] }, }
• Oct 22, 2024 •C S
0 likes • 2 views
function twoSum(nums: number[], target: number): number[] { const map = new Map(); for(let i = 0; i < nums.length; i++) { if(map.has(target - nums[i])) { return [map.get(target - nums[i]), i]; } else { map.set(nums[i], i); } } return [] } console.log(twoSum([1, 2, 3, 4, 5], 3))
• Oct 23, 2025 •opovolotskyi-7e4a
0 likes • 8 views
let state let prevValue function customState(initialValue){ if(state===undefined) { state=initialValue } function setState (newValue){ if(typeof newValue ==="function") { } state=newValue render() } return [state,setState] } setState(1) setState(2) setState((prev, next) => { return cancelIdleCallback() }) // state
function removeElement(nums: number[], val: number): number { let zeroStartIndex = 0; for(let i = 0; i < nums.length; i++) { if(nums[i] !== val) { nums[zeroStartIndex] = nums[i]; zeroStartIndex++; } } return zeroStartIndex; };
• Jun 1, 2023 •CodeCatch
interface Task { id: number; title: string; completed: boolean; } class TaskManager { private tasks: Task[] = []; constructor() {} addTask(title: string) { const taskId = this.tasks.length + 1; const task: Task = { id: taskId, title, completed: false, }; this.tasks.push(task); } markTaskAsComplete(taskId: number) { const task = this.tasks.find((task) => task.id === taskId); if (task) { task.completed = true; } } markTaskAsIncomplete(taskId: number) { const task = this.tasks.find((task) => task.id === taskId); if (task) { task.completed = false; } } listTasks() { console.log('Tasks:'); this.tasks.forEach((task) => { console.log(`${task.id}. [${task.completed ? 'X' : ' '}] ${task.title}`); }); } } // Example usage: const taskManager = new TaskManager(); taskManager.addTask('Buy groceries'); taskManager.addTask('Pay bills'); taskManager.addTask('Clean the house'); taskManager.listTasks(); // Output: // Tasks: // 1. [ ] Buy groceries // 2. [ ] Pay bills // 3. [ ] Clean the house