S/w Used : HTML, CSS, JavaScript with LocalStorage for storing data (little Bootstrap)
Framework Used : Text Editor
Description : A small addressbook which is having name, email, contact no, and city which is having CRUD operations.
Till Today :
From v1.0, design changed completely.
Code done for Adding new Contact with modal window.
And whenever new entry added that will get displayed in the table dynamically with del and edit buttons.
Delete button action also done.
Alignment I could not able to do well, so took chatGPT help.
To Do:
Edit action and Search are pending.
Add New screen is not getting closed after adding β has to be rectified.
Design should get changed in AddNew screen
Table β Headings font size should get changed. (As used bootstrap table class β th is not getting changed through css β have to research in it.
Some Code duplication is there, have to be optimized like keep in one function (inside validationPassed & addNewContact).
Technical WorkFlow:
function validationPassed : This function checks all the fields are not empty.
function getAddrBook : This function returns an Array which extracts the existing contacts from localStorage, if available, and parse it. Otherwise an empty array will be returned.
function addNewContact : If validationPassed, then new contact entry is created from 4 fields (Name, Email, ContactNo and City), together will form an object and pushed into addrBook array (got through getAddrBook) and will get saved into localStorage. showBook() function is getting called immediately to show the added contact.
function showBook() : This is actually a table where rows(contacts) with delete and edit buttons are getting added dynamically and will be shown.
function deleteCont(idx) : As the name suggests it will take the index of the array as input and delete the contact when the delete button pressed.
In losangels , a young coder named Lucifer set out on a mission to build his very own calculator. Along the way, he learned how to use Git, a powerful tool that would help him track his progress and manage his code. Hereβs the complete story of how Lucifer built his calculator, step by step, with the power of Git.
Step 1: Setting Up the Project with git init
Lucifer started by creating a new directory for his project and initializing a Git repository. This was like setting up a magical vault to store all his coding adventures.
mkdir MagicCalculator
cd MagicCalculator
git init
This command created the .git directory inside the MagicCalculator folder, where Git would keep track of everything.
Step 2: Configuring His Identity with git config
Before getting too far, Lucifer needed to make sure Git knew who he was. He configured his username and email address, so every change he made would be recorded in his name.
Step 3: Writing the Addition Function and Staging It with git add
Lucifer began his calculator project by writing a simple function to add two numbers. He created a new Python file named main.py and added the following code,
# main.py
def add(x, y):
return x + y
# Simple test to ensure it's working
print(add(5, 3)) # Output should be 8
Happy with his progress, Lucifer used the git add command to stage his changes. This was like preparing the code to be saved in Gitβs memory.
git add main.py
Step 4: Committing the First Version with git commit
Next, Lucifer made his first commit. This saved the current state of his project, along with a message describing what he had done.
git commit -m "Added addition function"
Now, Git had recorded the addition function as the first chapter in the history of Luciferβs project.
Step 5: Adding More Functions and Committing Them
Lucifer continued to add more functions to his calculator. First, he added subtraction,
# main.py
def add(x, y):
return x + y
def subtract(x, y):
return x - y
# Simple tests
print(add(5, 3)) # Output: 8
print(subtract(5, 3)) # Output: 2
He then staged and committed the subtraction function,
Step 6: Branching Out with git branch and git checkout
Lucifer had an idea to add a feature that would let users choose which operation to perform. However, he didnβt want to risk breaking his existing code. So, he created a new branch to work on this feature.
Now on the operation-choice branch, Lucifer wrote the code to let users select an operation,
# main.py
def add(x, y):
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
if y != 0:
return x / y
else:
return "Cannot divide by zero!"
def calculator():
print("Select operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
choice = input("Enter choice (1/2/3/4): ")
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == '1':
print(f"{num1} + {num2} = {add(num1, num2)}")
elif choice == '2':
print(f"{num1} - {num2} = {subtract(num1, num2)}")
elif choice == '3':
print(f"{num1} * {num2} = {multiply(num1, num2)}")
elif choice == '4':
print(f"{num1} / {num2} = {divide(num1, num2)}")
else:
print("Invalid input")
# Run the calculator
calculator()
Step 7: Merging the Feature into the Main Branch
After testing his new feature and making sure it worked, Lucifer was ready to merge it back into the main branch. He switched back to the main branch and merged the changes
git checkout main
git merge operation-choice
With this, the feature was successfully added to his calculator project.
Conclusion: Luciferβs Git-Powered Calculator
By the end of his adventure, Lucifer had built a fully functional calculator and learned how to use Git to manage his code. His calculator could add, subtract, multiply, and divide, and even let users choose which operation to perform.
Thanks to Git, Luciferβs project was well-organized, and he had a complete history of all the changes he made. He knew that if he ever needed to revisit an old version or experiment with new features, Git would be there to help.
Luciferβs calculator project was a success, and with his newfound Git skills, he felt ready to take on even bigger challenges in the future.