Wednesday, December 4, 2019

Find Your Friend's Birthday | Fun Project | JavaScript

Find Your Friend's Birthday | Fun Project


This is a fun project build with HTML and JavaScript.
Here, you store your friend’s birthdays, and search the friend’s name and get the birthday.
I make this today, I am feeling bored in the afternoon, so I made this, I know this is a very basic thing, but I want to share it with you. If you guys support me, I will make more advance project with JavaScript

If you guys want to design it, you are most welcome. Sent me the design in comments.

Watch the Tutorial Video





Source Code

Index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Find Birthday</title>
</head>
<body>
    <center>
        <h1>Find Your Friend's Birthday</h1>
        <input type="text" id="name" placeholder="Enter Your Friend's Name.."><br><br>
        <button onclick="findBirthday()">Find</button>
        <span id="match"></span>
    </center>
    
</body>
<script src="main.js"></script>
</html>


main.js


function findBirthday() {
    const birthdays = [
        {
            name"mainak",
            birthday"29th Nov"
        },
        {
            name"sohini",
            birthday"6th Dec"
        },
        {
            name"suparna",
            birthday"13th dec"
        },
        {
            name"indrajit",
            birthday"3rd sept"
        },
        {
            name"kunal",
            birthday"5th Nov"
        },
        {
            name"suvajit",
            birthday"20th jan"
        },
        {
            name"trayee",
            birthday"4th jully"
        },
        {
            name"avantika",
            birthday"27th jully"
        },
        {
            name"ritam",
            birthday"23th may"
        },
        {
            name"anirban",
            birthday"25th jan"
        },
        {
            name"subhajit paul",
            birthday"23th oct"
        },
        {
            name"debajyoti bhunia",
            birthday"23th sept"
        }

    ]

    const n = document.getElementById("name").value
    console.log(n);
    
    const name = n.toLowerCase()

    for (let i = 0; i < birthdays.length; i++) {
        if (birthdays[i].name === name) {
            console.log(birthdays[i].birthday);
            // alert(birthdays[i].birthday)
            document.getElementById("match").innerHTML = `
                <p>The birthday of ${n} is ${birthdays[i].birthday}</p>
            `
            break
        } else {
            // console.log("No match");
            document.getElementById("match").innerHTML = `
                <p>No Match</p>
            `
        }
    }
}






5 comments:

  1. Best Advanced excel institute in Delhi/Noida is High Technologies Soloutions which provides best training in advanced excel. All the trainers have 5+ years experience in their fields. HTS focus more on practical knowledge than theory which makes training sessions more interesting and trainers focus on individual training as well.HTS provides 100% placement help. Join now!! Call at +919311002620 or visit our website.
    advanced excel course in Delhi
    advanced excel course in Noida

    ReplyDelete
  2. Join the best Autocad leading institute in Delhi and Noida. High technologies Solutions provides the best AutoCAD course with the very basic of CAD design to advanced CAD.Experienced trainers and 100% placement help. Call +9311002620.
    autocad training institute in Delhi
    autocad training institute in Noida

    ReplyDelete