Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kavya5c0 authored Mar 24, 2024
1 parent b53bde2 commit 779b2cb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<style>
body {
font-family: Arial, sans-serif;
background-image: url('background_image.jpg'); /* Replace 'background_image.jpg' with the path to your background image */
background-size: cover;
background-position: center;
background-repeat: no-repeat;
Expand Down Expand Up @@ -47,6 +48,10 @@ <h3>Edit/Delete Options</h3>
<script>
function calculateFrequency() {
var inputString = document.getElementById("inputString").value;
if (inputString.trim() === "") {
alert("Please enter a string.");
return;
}
var frequency = {};
for (var i = 0; i < inputString.length; i++) {
var char = inputString.charAt(i);
Expand All @@ -69,16 +74,32 @@ <h3>Edit/Delete Options</h3>

function editCharacter() {
var editCharacter = document.getElementById("editCharacter").value;
if (editCharacter.trim() === "") {
alert("Please enter the character to edit.");
return;
}
var newCharacter = document.getElementById("newCharacter").value;
var inputString = document.getElementById("inputString").value;
if (!inputString.includes(editCharacter)) {
alert("Character to edit is not present in the input string.");
return;
}
var updatedString = inputString.replace(editCharacter, newCharacter);
document.getElementById("inputString").value = updatedString;
calculateFrequency();
}

function deleteCharacter() {
var deleteCharacter = document.getElementById("deleteCharacter").value;
if (deleteCharacter.trim() === "") {
alert("Please enter the character to delete.");
return;
}
var inputString = document.getElementById("inputString").value;
if (!inputString.includes(deleteCharacter)) {
alert("Character to delete is not present in the input string.");
return;
}
var updatedString = inputString.split(deleteCharacter).join("");
document.getElementById("inputString").value = updatedString;
calculateFrequency();
Expand Down

0 comments on commit 779b2cb

Please sign in to comment.