Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

updated code #179

Copy link
Copy link
@abhi-1207

Description

@abhi-1207
Issue body actions
<title>App</title> Add
<button class="remove">Remove</button>

<script>

  const add =document.querySelector('.add');
  const remove =document.querySelector('.remove');
  add.addEventListener('click',()=>{
      messages++;
      storeMsg()
     displayNotification()
  })
  remove.addEventListener('click',()=>{
    if (messages > 0) {
    messages--;
    storeMsg()

    if (messages === 0) {
      document.title='App';
    }
  }

  })

  let messages = Number(localStorage.getItem('strMsg')) ||0;

  // Save the intervalId in case we need to cancel it.
  let intervalId;

  // We'll use this variable to keep track of whether
  // or not we're displaying the notification.
  let isDisplayingNotification;

  // Start displaying the notification in the tab
  // when the page first loads.
  displayNotification();

  function displayNotification(){
    // If we're already displaying the notification,
    // stop this function because we don't want to
    // create 2 intervals at the same time.
    if (isDisplayingNotification) {
      return;
    }

    isDisplayingNotification = true;

    intervalId = setInterval(()=> {
      if (messages === 0) {
      document.title='App';
    }else if (document.title === 'App') {
        document.title = `(${messages}) New messages`;
      } else {
        document.title = 'App';
      }
    }, 1000);
  }

  function stopNotification() {
    isDisplayingNotification = false;

    clearInterval(intervalId);
    document.title = 'App';
  }

  function storeMsg(){
    localStorage.setItem('strMsg',messages.toString());
  }


  // Grouping the JavaScript code into a function
  // is optional, but it is a bit cleaner.
  // const updateButton = ()=> {
  //   const button = document.querySelector('.js-button');
  //   setTimeout(()=> {
  //     button.innerHTML = 'Finished!';
  //   }, 1000);
  // }

  // const button = document.querySelector('.js-button');
  //  button.addEventListener('click',updateButton);

// console.log(multi(2,4));

// const multi = (num1,num2)=> num1*num2;

// console.log(multi(2,4));

// console.log(
// array.filter((value,i)=>{
// if(value>=10){
// return true;
// }else {
// return false;
// }
// })
// );

// console.log(
// array.map((value,i)=>{
// return i*2
// })
// );

// const hell = () => {
//   console.log('hell');
// }
// hell();

//  setTimeout(() => {
//   console.log('hell');
// },1000)

  // let num=0;

          //  function isClick(){

          //   const btnCont = document.querySelector('.add');
          //   const btnContR = document.querySelector('.remove');

          //   if(btnCont.classList.contains('add')){
          //     num++;

          //   }else if(btnContR.classList.contains('remove')){
              
          //   if(num>0){
          //     num--;
          //   }else {
          //     num =0;
          //   }
          //   }



          //  }

          //  function isClickR(){
          //   if(num>0){
          //     num--;
          //   }
          //   else if(num <= 0){
          //       document.title= 'App';
          //    }
          //  }

          //  function isClickR(){
          //   if(num>0){
          //     num--;
          //     if(num ===0){
          //       document.title= 'App';
          //    }
          //   }
            // else if(num <= 0){
            //     document.title= 'App';
            //  }
          //  }
   
    //  setInterval(function () {
    //    if(num > 0){
    //   if ( document.title === 'App') {
    //     document.title = `(${num}) New Messages`;
    //   }else {
    //      document.title= 'App';
    //   }
    // }
    // }, 1000);
  

  //   let timeoutId;

  // function ifClick() {
  //   const messageElement = document.querySelector('.added');
  //   messageElement.innerHTML = 'Added';

    // First, cancel the previous timeout so that
    // it doesn't remove the message too quickly.
  //   clearTimeout(timeoutId);

  //   timeoutId = setTimeout(function() {
  //     messageElement.innerHTML = '';
  //   }, 2000);
  // }
  
  // const btn =document.querySelector('.finished');
  // function ifClick(){
  //   setTimeout(function(){
  //     if(btn.innerText ==='Start'){
  //       btn.innerHTML = 'Finished!';
  //     }else{
  //       btn.innerHTML = 'Start';

  //     }
  //   },1000)
  // }
           
//       const neww = function(func){
//         console.log('constant');
//         func();
//       }
     

//  setTimeout(neww(function(){

//  }){
//   console.log('constant');
//  },
//   800)


    //  setTimeout(function(){
    //   console.log('Hello')
    //  }, 5000)
 

  // const stringNot = ['hellow','rajan', 'raju','getin','lion','fire','water','fire','lion','rajan'];


  //     function findIndex(array, word) {
  //   for (let i = 0; i < array.length; i++) {
  //     if (array[i] === word) {
  //       return i;
  //     }
  //   }

  //   return -1;
  // }

  // function uniqueArr(arrayy){
  //   let unqArray = [];

  //    for (let i = 0; i < arrayy.length; i++) {
  //        const words = arrayy[i];

  //    if (findIndex(unqArray, words)==-1){
  //     unqArray.push(words);
  //    }
  //    }
  //    console.log(unqArray);
  // }
  //        uniqueArr(stringNot);

    //  for(let i=1; i<=20;i++){
    //    if(i%3===0 && i%5===0){
    //      console.log('Fizz');
         
    //   }
    //    else if(i%5===0){
    //      console.log('Buzz');
         
    //   }
    //    else if(i%3 === 0){
    //      console.log('FizzBuzz');
         
    //     }else {
    //      console.log(i);
    //     }
    //   }
        
      // const stringNot = ['hellow', 'raju','getin','fire','water','lion','rajan'];

      // const string = ['hellow', 'raju','egg','getin','fire','egg','water','egg','rajan'];

      //   function removeEgg(foodList){
      //     let wtoutEgg = [];
      //     let count = 0;

      //     const copyArr= foodList.slice();
      //     // console.log(copyArr)
      //     const reverseArr= copyArr.reverse();
      //     // console.log(reverseArr)

      //     for(let i=0; i<reverseArr.length;i++){

      //         if(reverseArr[i]==='egg' && count < 2){

      //           count++;
      //           continue;
      //           // foodList.splice(i,1);
      //         }
      //         wtoutEgg.push(reverseArr[i]);
              
      //       }
      //       console.log(wtoutEgg);
      //     }

      //     removeEgg(stringNot);
      //     removeEgg(string);
      //   function removeEgg(foodList){

      //     // let count = -1;
      //     for(let i=0; i<foodList.length;i++){

      //         if(foodList[i]==='egg'){
                  
      //           foodList.splice(i,1);
      //         }
              
      //       }
      //       console.log(foodList);
      // }
   
// const stringNot = ['hellow', 'raju','getin','fire','water','lion','rajan'];
// const stringarr = ['hellow', 'raju','getin','fire','water','lion','search','rajan'];

// function isContain(){
//   // let dblArr=[];
  
//   let count =0 ;
//   for(let i=0; i<stringarr.length;i++){

//     if(stringarr[i]==='search'){
//       count = i;
//       console.log(count);
//       return;
//     }else{
//       count = -1;
      
//     }
    
//   }
//   console.log(count);
// }

// isContain();
// isContain(stringNot);

  // let i = 0;

  // while (i<=10){
  //       if(i%3===0){
  //         i++
  //       continue;
  //       }
  //   console.log(i);
  //   i++
  // }

  // for(let i = 1; i<=10 ; i++){

      // if(i%3===0){
      //   continue;
  //     }

  //   //   if(i===9){
  //   //   break;
  //   // }
  //   console.log(i);
    
  // }
  
  // console.log(12%3);


  // const array =[5,9,8,0];
  // // console.log(array);
  // const newarr = array.slice() ;
  // // console.log(newarr);
  // newarr.push(56);
  // console.log(newarr);
  // console.log(array);

  // const [first,sec,fourth] =[5,9,8,0];
  // console.log(first)
  // console.log(sec)
  // // console.log(third)
  // console.log(fourth)




  //  function countWords(words) {
  //   const result = {};

  //   for (let i = 0; i < words.length; i++) {
  //     const word = words[i];

  //     // result[word] adds/accesses a property using whatever is
  //     // saved inside the 'word' variable.
  //     // If word = 'apple', result[word] will do result['apple']
  //     // If word = 'grape', result[word] will do result['grape']
  //     if (!result[word]) {
  //       result[word] = 1;
  //     } else {
  //       result[word]++;
  //     }
  //   }

  //   return result;
  // }

  // console.log(countWords(['apple', 'grape', 'grape', 'apple', 'apple']));

 
//  let myArr=[2,-9,0,-3,-8,5,7];
//  let myArrr=[2,9,0,-3,8,-5,7,6];
//  let myAr=[3];

//  function minMaxNums(array){
//   const minMaxobj ={
//     min: null, max: null
//   }
//   for(let i=0;i<array.length;i++){
//        const arrNum = array[i];

//     if( arrNum> minMaxobj.max || minMaxobj.max == null ){
//          minMaxobj.max = arrNum ;
//     }
//      if( arrNum <minMaxobj.min || minMaxobj.min == null ){
//          minMaxobj.min = arrNum ;
//     }
//   }
//   console.log(minMaxobj);
// }
    // if(array[i]>0){
    //   minMaxobj.max++
    // }else if(array[i]<0){
    //   minMaxobj.min++
    // }
    
    // else if(array.length===0){
    //   minMaxobj.min= 'null'
    //   minMaxobj.max= 'null'
    //   minMaxobj.zero= 'null'
    // }
//     else{
//       minMaxobj.zero++
//     }
//   }console.log(minMaxobj);
//  }
//  minMaxNums(myArr);
//  minMaxNums(myArrr);
//  minMaxNums(myAr);
//  minMaxNums([]);

   
//  countPositive(myArr);
//  countPositive(myArrr);


//  let myArr=[2,-9,0,-3,-8,5,7];
//  let myArrr=[2,9,0,-3,8,-5,7,6];

//  function countPositive(array){
//   count = 0;
//   for(let i=0;i<array.length;i++){
//     if(array[i]>0){
//       count++
//     }
//   }console.log(count);
//  }
   
//  countPositive(myArr);
//  countPositive(myArrr);

 
//  function addArrays(Array1=0,Array2=0){
//   let arrLen = 0;
//   if(Array1.length>Array2.length){
//     arrLen = Array1.length ;
//   }else {
//     arrLen = Array2.length;
//   }
//    const resultArr = [];

//   for(let i=0;i<arrLen;i++){
//     if(Array1[i]){
//       Array1[i]=0;
//     }else if(Array2[i]===NaN){
//       Array2[i]=0;
//     }
    
//     resultArr.push(Array1[i]+Array2[i]);
    
//   }
//   console.log(resultArr);
//  }
  
//  addArrays(myArr,myArrr);
 

//  function addNum(Array,Num){
//      let newArr=[];
//    for(let i=0; i<Array.length;i++){
//     const multiNum = Array[i];
//      newArr.push(multiNum+Num)
     
//    }
//    console.log(newArr);
//  }

//  addNum(myArr,7);
 
// i=0
// while(i<myArr.length){
   
//    let num = myArr[i];
//    newArr.push(num*2);

//    i++
// }
//   console,console.log(newArr);

  // const nums =[10, 20, 30, 40];

  // for(let i=5;i>=0;i--){
  //   console,console.log(i);
    
  // }

  // console.log(nums);
  // nums.pop()
  // console.log(nums);
  // nums.push(99)
  
  // function getLastValue(inputArray){
  //   const lastEl = inputArray.pop();
  //   return lastEl;
  // }
  // console.log(getLastValue(nums));

  // function getSwapedArray(inputArray){
  //   const firstEl = inputArray[0];
  //   inputArray[0] = inputArray[inputArray.length-1];
  //   inputArray[inputArray.length-1] = firstEl;

  //   // const lastEl = inputArray.pop();
  //   return inputArray;
  // }
  // console.log(getSwapedArray(nums));

  // function getLastValue(inputArray){
  //   const lastEl = inputArray[inputArray.length-1];
  //   return lastEl;
  // }
  // console.log(getLastValue(nums));
  //   const toDoArray = ['do work','play games', 'go home'];

  // for (let i=0; i<toDoArray.length;i++){
  //             const listEl  = toDoArray[i] ;
  //             const theList= document.querySelector('.to-do-list');
  //               theList.innerHTML += `<p> ${listEl}</p>`;
  //           }

// let random = 0;
// while(random< 0.5 ){
// random = Math.random();
// console.log(random);
// }

// const arrayIs= [23,5,22,95,63,73,47,63,28,53,6,12];
// let sumOfAr = 0;
// for(let i=0;i<arrayIs.length;i++){
// sumOfAr += arrayIs[i];
// }
// console.log(sumOfAr);

// const arrayIs= [23,5,22,95,63,73,47,63,28,53,6,12];
// let sumOfAr = [];
// for(let i=0;i<arrayIs.length;i++){
// const num = arrayIs[i];
// sumOfAr.push(num*2);
// }
// console.log(sumOfAr);

// const myArray = [1, 'ronak',true, 23, 25, 52, 68, 'raju', 'aaju','sanju', 'manju', 'ranju' ];

// console.log(myArray[2]);
// console.log(myArray[7]);
// console.log(myArray[3]);
// console.log(myArray[6]);
// console.log(myArray.length);
// console.log(myArray);
// myArray.pop(23);
// myArray.pop([7]);
// console.log(myArray);
// console.log(myArray.length);
// // console.log(myArray[11]);
// myArray.push('madhav');
// console.log(myArray);
// console.log(myArray.length);
// // console.log(myArray[11]);
// myArray.splice(4,3)
// console.log(myArray);



// console.log(document.querySelector('.amzon-btn').classList.contains('js-btn'));


// function gamingBtn(forall){
//   const gmngBtn = document.querySelector(forall);
//   if(!gmngBtn.classList.contains('is-toggled')){
//     turnOff();
//      gmngBtn.classList.add('is-toggled');
//   }else{
//      gmngBtn.classList.remove('is-toggled');
//   }
  
// }
// function turnOff(){
//    const turnOffBtn = document.querySelector('.is-toggled');
//   if(turnOffBtn){
//      turnOffBtn.classList.remove('is-toggled');
//   }
// }
// The word "toggle" means turn on/off.

// function gamingBtn(forall) {
// const gmngBtn = document.querySelector(forall);
// if (!gmngBtn.classList.contains('is-toggled')) {

// // Before turning this button ON, check if there's
// // already a button that's turned ON and turn it OFF.
// turnOff();

// gmngBtn.classList.add('is-toggled');
// } else {
// gmngBtn.classList.remove('is-toggled');
// }
// }

// function turnOff() {
// const turnOffBtn = document.querySelector('.is-toggled');
// if (turnOffBtn) {
// turnOffBtn.classList.remove('is-toggled');
// }
// }

// function textShower(){
// const inputText = document.querySelector('.inputText');
// const showHere = document.querySelector('.showHere');
// showHere.innerHTML=inputText.value

// }

// function showText(){
// let inputName = document.querySelector('.inputName').value
// document.querySelector('.resultText').innerHTML = Your Name Is ${inputName.toUpperCase()};
// }

// function onEnter(){
// if(event.key=='Enter'){
// showText();
// }
// }

// console.log(document.querySelector('button'));
// document.querySelector('.change').innerHTML= '9b done!';
// function userPick(userPick){
// let pick =document.querySelector('.chosen');
// if(userPick==='heads'){
// pick.innerHTML = You chose: ${userPick};
// }else {
// pick.innerHTML = You chose: ${userPick}
// }
// }

// function convertLength(lenght,from,to){
//   if(from==='km' && to !='km'){
//     console.log(`Converted: ${lenght/1.6} ${to}`);
//   }else if(from==='miles'||'mile'){
//     console.log(`Converted: ${lenght*1.6} ${to}`);
//   }else if(from==='km' && to==='km'){
//     console.log(`Converted: ${lenght} ${to}`);
//   }
// }
//  convertLength(10,'miles','km')
//  convertLength(10,'km','mile')
//  convertLength(10,'km','km')
//  convertLength(10)
// function convertLength(lenght, from, to) {
//   if (from === 'km' && to === 'miles') {
//     console.log(`Converted: ${lenght / 1.6} ${to}`);
//   } else if (from === 'km' && to != 'km' && to === 'feet') {
//     console.log(`Converted: ${lenght * 3281} ${to}`);
//   } else if (from === 'miles' && to === 'km') {
//     console.log(`Converted: ${lenght * 1.6} ${to}`);
//   } else if (from === 'miles' && to === 'feet') {
//     console.log(`Converted: ${lenght * 5280} ${to}`);
//   } else if (from === 'km' && to === 'km') {
//     console.log(`Converted: ${lenght} ${to}`);
//   } else if (from === 'feet' && to==='miles') {
//     console.log(`Converted: ${lenght / 5280} ${to}`);
//   }else if (from === 'feet' && to==='km') {
//     console.log(`Converted: ${lenght / 3281} ${to}`);
//   }else if(from!=='miles' || from!=='km'|| from!=='feet' || to!=='miles' || to!=='km'|| to!=='feet'){
//     console.log('Invalit Unit');
//   }
// }
// convertLength(5, 'miles', 'km')
// convertLength(10, 'km', 'miles')
// convertLength(5, 'km', 'feet')
// convertLength(5, 'miles', 'feet')
// convertLength(10, 'feet', 'km')
// convertLength(10, 'feet', 'miles')
// convertLength(10, 'litter', 'km')
// convertLength(10, 'km', 'gm')
// convertLength(10, 'ml', 'am')
// convertLength(10, 'meter', 'killo')
// convertLength(10)


//  let name = 'Abhishek';
//     console.log(`My Name Is: ${name}`);

//  let cost = 5+2*3+9;
//  let tax = cost*0.1;
//  let totalCost = cost + tax ;
//  console.log(`Cost of Food: $${cost}`);
//  console.log(`tax On Food: $${tax}`);
//  console.log(`Tatal Cost of Food: $${totalCost}`);
// if (false){

//     console.log(67==67);}

// const result = 0 ? 'yes' : 'no'
// console.log(result);

// let hour = 6;
// const name = 'abhishek';
// if(hour>=6 && hour<=12){
//     alert('Good Morning ' + name);
// }else if (hour>12 && hour<=17){
//     alert(`Good Afternoon ${name} `);
// } else {
//     alert('Good Night.....!');
// }
// const isHoliday=false;
// let age = 5;
// if((age<=6 || age>=65) && !isHoliday){
//     alert('Eligible');
// }else{
//     alert('Not Eligible');
// }
// let comPick ;
//   let num ;
//   function comMove(){
//     num = Math.random();
//  if (num < 0.333) {
//   comPick = 'Rock';
//  } else if (num >= 0.333 && num < 0.666) {
//   comPick = 'Paper';
//  } else if (num >= 0.666) {
//   comPick = 'Scissors';
// }
//   console.log(num);
//   console.log(comPick);
//   }
//   function resultOfMove(para1,para2,para3){
// let result ;
// if(comPick===para1){
//    result = 'Tie';
//  }else if(comPick===para2){
//    result = 'You Lose';
//  }else if(comPick===para3){
//    result = 'You Won';

//  };
//  console.log(result);
// }
// function taxCalculator(value){
//   let result;
//   result=value*0.1;
//   console.log(result)

// }
// let result;
// let num;
// let comPick;

// function pickCompMove() {

//   num = Math.random();

//   if (num < 0.333) {
//     comPick = 'Rock';
//   } else if (num >= 0.333 && num < 0.666) {
//     comPick = 'Paper';
//   } else if (num >= 0.666) {
//     comPick = 'Scissors';
//   }

//   return comPick;
// }

// function resultOfMove(para1, para2, para3) {
//   comPick = pickCompMove();
//   if (comPick === para1) {
//     result = 'Tie';
//   } else if (comPick === para2) {
//     result = 'You Lose';
//   } else if (comPick === para3) {
//     result = 'You Won';

//   } console.log(result);
// }
// function greet(name){
// !name ? console.log('Hii there!') : console.log(`Hello! ${name}`);
// }
// greet();
// greet('abhi');
// greet('evos');
// greet();
// greet();
// function convertToFahrenheit(celsius) {
//   console.log(`Answer: ${(celsius * 9 / 5) + 32} F`);
// }
// function convertToCelsius(Fahrenheit) {
//   console.log(`Answer: ${(Fahrenheit - 32) * 5 / 9} C`);
// }

// function convertTemp(degrees, unit) {
//   if (unit === 'C') {
//     convertToFahrenheit(degrees)
//   } else if (unit === 'F') {
//     convertToCelsius(degrees)
//   } else {
//     console.log('Invalid Input');
//   }
// }
// convertToCelsius(86);
//       function convertToFahrenheit(value,unit){
//     if(unit==='C'){
//     console.log(`Answer: ${ (value*9/5)+32} F`);
//     }else if(unit==='F'){
//     console.log(`Answer: ${ (value-32)*5/9} C`);
//     }else{
//       console.log('Invalid Input');
//     }
//   }
//  convertTemp(25,'C');
//  convertTemp(86,'F');
//  convertTemp(66,'G');
//  convertTemp(73);
//  convertTemp();
// const product={
//   v1: 780,
//   v2 : 609,
//   v3: 860,
//   v4 : 200,
//   v5: 50,
//   v6 : 60,

// }
// console.log(product.v1-product.v3);
// console.log(product.v2);
// console.log(product['v2']+product['v5']);
// console.log(product.v4);


// alert(`Wins: ${product.price}`);


// let word = 'First';
// console.log(word);
// word = 'firstWork';
// console.log(word);
// console.log('hello'.length);
// console.log('hello'.toUpperCase());
// console.log('hello'.length);

// const obj1 = {
//   price: 100,
//   value: 9.99,
//   name: 'sanju'
// };
// // console.log(obj1);
// // console.log(obj1.value);
// const obj2 = {
//   price: 150,
//   value: 9.559,
//   name: 'raju'}
// // };
// // console.log(obj2.name);
// // console.log(obj2.price);
// console.log();
// console.log();
// const obj4 = {
//   price: 200,
//   value: 9.865,
//   name: 'kajju',
//   obj3: {
//     price: 170,
//     value: 9.986,
//     name: 'unknw',
//     obj2: {
//       price: 150,
//       value: 9.559,
//       name: 'raju'
//     }
//   }

// }
// const obj5 = obj4;
// console.log(obj5);

// const neww = obj4.name;
// const {name} = obj4;
// console.log(neww);
// console.log(name);

//  console.log(name);
// console.log(obj4.obj3.name);

// obj4.name = 'raaajjuu';
// obj4.obj3.name = 'rahuuuuuuuuu';


//    console.log(obj4.name);
// console.log(obj4.obj3.name);





// console.log(obj4.obj3.obj2.name);
// console.log(obj4.obj3.value);


// const product ={
//   name : 'basketball',
//   price: 2029,
//   ['delivery-time']: '3days'
// };
// product.price += 500;
// product.price = product.price+500;
// product.price = 2029+500;
// console.log(product);

//    const product11 ={
//   name : 'cricketBat',
//   price: 500,
//    }
//    const product12 ={
//   name : 'cricketBat',
//   price: 4500,
//    }

// function comparePrice(product1,product2){
//   if(product1.price<product2.price){
//     return product1;
//   }else if (product1.price>product2.price){
//     return product2;
//   }else{
//     console.log('Both have Same Price');
//     return 'buy any one';
//   }
// }
// const productWithLessPrice = comparePrice(product11,product12);

// console.log(productWithLessPrice);
// const product11 = {
//   name: 'bascketBall',
//   price: 500,
// }
// const product12 = {
//   name: 'cricketBat',
//   price: 4500,
// }
// const product13 = {
//   name: 'cricketBat',
//   price: 4500,
// }


// function isSameProduct(product1, product2) {
//   return (product1.price===product2.price &&
//           product1.name===product2.name);
// }
// console.log(isSameProduct(product11, product12));
// console.log(isSameProduct(product13, product12));
// console.log(isSameProduct(product13, product12));


// console.log('test'.repeat(9));
</script>
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.