Skip to content

Commit

Permalink
Create financialLiteracy.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 4, 2024
1 parent 95f7b70 commit 5b3dfbb
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/education/financialLiteracy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// financialLiteracy.js

class FinancialLiteracy {
constructor() {
this.resources = []; // Store financial literacy resources
}

// Add a new resource
addResource(title, type, url, description) {
const resource = {
id: this.resources.length + 1,
title,
type,
url,
description,
};
this.resources.push(resource);
console.log(`Resource added: ${title}`);
}

// Get all resources
getAllResources() {
return this.resources;
}

// Get resource by ID
getResourceById(id) {
return this.resources.find(resource => resource.id === id) || null;
}

// Search resources by title
searchResourcesByTitle(searchTerm) {
return this.resources.filter(resource =>
resource.title.toLowerCase().includes(searchTerm.toLowerCase())
);
}
}

// Example usage
const financialLiteracy = new FinancialLiteracy();
financialLiteracy.addResource('Understanding Credit Scores', 'Article', 'https://example.com/credit-scores', 'Learn about credit scores and how they affect your financial health.');
financialLiteracy.addResource('Investing 101', 'Video', 'https://example.com/investing-101', 'A beginner\'s guide to investing.');
financialLiteracy.addResource('Budgeting Basics', 'Course', 'https://example.com/budgeting-basics', 'Learn how to create and stick to a budget.');

console.log('All Resources:', financialLiteracy.getAllResources());
console.log('Search Results for "Investing":', financialLiteracy.searchResourcesByTitle('Investing'));

0 comments on commit 5b3dfbb

Please sign in to comment.