# Even Numbers 1 to 100

``` Even Numbers Meaning - Even Numbers are numbers that are divisible by 2 and generate zero as the remainder. Even numbers from 1 to 100 include 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100. In this article, you will read about What are Even Numbers, their meaning and definition, List of Even Numbers from 1 to 100, How to know if a number is even or odd, Even Numbers that are Prime, the Properties of Even Numbers, Difference between Odd Numbers and Even Numbers, Even Numbers on the Number Line, along with some practice problems and solved examples on even numbers. Table of Content What are Even Numbers? List of Even Numbers  List of Even Numbers 1 to 100 List of Even Numbers 1 to 200 Odd Numbers and Even Numbers How to Know If a Number is Even or Odd? Even Natural Numbers Properties of Even Numbers Even Numbers that are Prime Even Numbers on the Number Line Even Numbers Solved Examples Practice Questions on Even Numbers 1 to 100 What are Even Numbers? Any number that can be exactly divided by 2 is called an even number. Even numbers always end up with the last digit as 0, 2, 4, 6 or 8. Some examples of even numbers are 2, 4, 6, 8, 10, 12, 14, 16. Imagine you have a certain number of candies. If these candies can be divided equally between two individuals, resulting in the same number of candies for each person, then the original quantity of candies must have been an even number. Even numbers can be easily divided into two equal pairs. Thus, by the above explanation 12, 16, 8, etc. are even numbers and 7, 11, 13, etc. are not even numbers. Negative numbers that are exactly divisible by two are also considered even numbers such as -4, -6, -18, etc. Even Numbers Definition Even Numbers are the integers that on division by 2 result in a remainder of 0. It is of the form 2n, where n is any integer. The image added below shows some even numbers. Note: All integers are either even numbers or odd numbers. List of Even Numbers It is not possible to list out all even numbers, as there are an infinite number of them. However, we can list the initial even numbers, which include positive even numbers such as 2, 4, 6, 8, 10, and so on, extending to infinity, as well as negative even numbers such as -2, -4, -6, -8, -10, and so on, extending to negative infinity. 0 is considered an even number because it is divisible by 2 (2 divides 0 with a remainder of 0). List of Even Numbers 1 to 100 Even numbers 1 to 100 as they suggest are the even numbers from 1 to 100. There are fifty even numbers from 1 to 100. The image added below highlights the even numbers from 1 to 100. Even Numbers between 50 and 70 Even numbers between 50 and 70 are, 52, 54, 56, 58, 60, 62, 64, 66, 68. List of Even Numbers 1 to 200 Even Numbers 1 to 200 are the consecutive even numbers starting from 2 and till 198, there are a total of 100 even number between 1 to 200, the table added below, shows the even number from 1 to 200 2 22 42 62 82 102 122 142 162 182 4 24 44 64 84 104 124 144 164 184 6 26 46 66 86 106 126 146 166 186 8 28 48 68 88 108 128 148 168 188 10 30 50 70 90 110 130 150 170 190 12 32 52 72 92 112 132 152 172 192 14 34 54 74 94 114 134 154 174 194 16 36 56 76 96 116 136 156 176 196 18 38 58 78 98 118 138 158 178 198 20 40 60 80 100 120 140 160 180 200 Odd Numbers and Even Numbers There are some major differences between even and odd numbers. We have listed most of them down below: Even Numbers Odd Numbers Those numbers which are exactly divisible by 2 are even numbers. Those numbers which are not exactly divisible by 2 and give 1 asa reminder when divided by 2 are Odd numbers. Examples of positive even numbers are 2, 4, 6, 8, 10, etc. Examples of positive odd numbers are 1, 3, 5, 7, 9, etc. Examples of negative even numbers are -2, -4, -6, -8, -10, etc. Examples of negative odd numbers are  -1, -3, -5, -7, -9, etc. All the even numbers can be represented by 2k, where k is some integers. All the odd numbers can be represented by 2k+1, where k is some integers. How to Know If a Number is Even or Odd Any number ending with digits 0, 2, 4, 6, and 8, is an Even Number, as all the numbers ending with digits 0, 2, 4, 6, and 8 are divisible by 2. Also, numbers ending with digits 1, 3, 5, 7, and 9 are odd numbers, as they are not divisible by 2 and give 1 as the remainder when divided by 2. Here is the way you can know how to now If a Number is Even or Odd. Example: Classify the numbers as odd and even from the following? 10880, 16619, 2314, 1923, and  23468 Numbers ending with 0, 2, 4, 6, and 8 are even numbers. Thus, 10880, 2314, and 23468 are even numbers from the given list.  Numbers ending with 1, 3, 5, 7, and 9 are odd numbers. Thus, 16619 and 1923 are the odd numbers from the given list. Consecutive Even Numbers Consecutive even numbers are the even numbers that have a difference of 2 between any two numbers that come to one another. That is we can say that if we list even numbers without skipping any numbers then it is said to be consecutive even numbers. Suppose we write, 6, 8, 10, and 12 then it is considered to be a consecutive even number and if the even number is written as, 4, 8, 14 then they are not considered to be a consecutive even number. Even Natural Numbers Natural numbers are the numbers that are used for counting and natural numbers that are also even numbers are called even natural numbers. Some examples of even natural are 2, 8, 14, 18, etc. Properties of Even Numbers One major property of Even Numbers is that all Even Numbers can be represented as 2k whereas for all k belongs to integers. For example, 14 can be written as 2Ã—7, and -10 can be written as 2Ã—-5.  Other than this property, there are some operation-oriented properties of even numbers which are as follows: Property of Addition of Even Numbers Addition of two or more even numbers always results in an even number. For example, 2 + 4 + 6 + 10 = 22 Addition of two odd numbers always results in an even number. For example, 3 + 7 = 10, 7 + 9 = 16, etc. Addition of one even and one odd number always results in an odd number. For example, 2 + 3 = 5, 4 + 3 = 7, and 11 + 4 = 15, etc. Property of Subtraction of Even Numbers Subtraction between any two even numbers always results in an even number. For example, 4 - 6 = 2, 12 - 14 = -2, and 24 - 14 = 10, etc. Subtraction of two odd numbers always results in an even number. For example, 5 - 3 = 2, 9 - 5 = 4, etc. Subtraction between one even and one odd number is always an odd number. For example, 4 - 7 = 3, 3 - 14 = 11, and 13 - 14 = -1, etc. Property of Multiplication of Even Numbers Multiplication of two even numbers is always an even number. For example, 2 Ã— 4 = 8, 12 Ã— 10 = 120, and 8 Ã— 6 = 48, etc. Multiplication of one even and one odd number is always an even number. For example, 3 Ã— 4 = 12, 2 Ã— 15 = 30, and 4 Ã— 7 = 28, etc. Even Numbers that are Prime For any number to be prime, it's only possible factors can be 1 and the number itself but all even numbers have 2 as their factor, therefore even numbers can't be prime. But there is one exception to this rule as 2 is the prime as well as even number. Thus, 2 is the only even number that is prime as well. Even Numbers on the Number Line A number line is a line in which numbers are marked and is used to marks the position of various numbers and perform all sort of mathematical operations such as addition, subtraction, and others. Even numbers are easily represented on the number line. They are represented by skipping one number and marking the other number starting from any even number. The image added below shows even numbers on a number line, Even Numbers Solved Examples Here are some solved examples on Even Numbers to help you learn how to solve the questions on even numbers: Example 1: Write any 10 consecutive even numbers between 1 and 50. Solution: As, every other number in a continuous series of natural numbers is even number. So, 2, 4, 6, 8, 10, . . ., 48, 50 is the list of all even numbers between 1 and 50. Thus, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 or 12, 14, 16, 18, 20, 22, 24, 26, 28, 30 or 22, 24, 26, 28, 30, 32, 34, 36, 38, 40 are some of the examples of 10 consecutive even numbers between 1 and 50. Example 2: How many even numbers are between 1 and 300? Solution: Out of all integers, half of them are even and half of them are odd. So, there are 300 integers between 1 and 300 (including 1 and 300), so half of them are odd and half of them are even. Thus, there are 150 even number between 1 and 300. Example 3: Find the product of all even numbers between 1 to 10. Solution: The Even numbers between 1 to 10 are 2, 4, 6, 8, and 10. The product of all even numbers between 1 to 10 = 2 * 4 * 6 * 8 * 10 = 3840. Thus, product of all even numbers between 1 and 10 (including 1 and 10) is 3840. Example 4: What is the even natural number that can be written as the sum of two odd primes? Solution: The sum of two odd numbers is always even. Therefore, the smallest even number that can be written as the sum of two odd primes is 8. The smallest two odd primes are 3 and 5. Their sum is 8, which is also even. Therefore, the smallest even number that can be written as the sum of two odd primes is 8. Example 5: Find the sum even numbers from 10 to 20. Solution: Even Numbers from 10 to 20 are 12, 14, 16, 18 Sum = 12 + 14 + 16 + 18 Sum = 60 Thus, the sum of even numbers from 10 to 20 is 60 Example 6: Find the difference of 28 and 16 Solution: Difference of 28 and 16 = 28 - 16 = 12 Practice Questions on Even Numbers 1 to 100 Here are some practice questions on even numbers 1 to 100 for you to solve: Q1. Find the sum of even numbers from 20 to 40 Q2. Check if the number given are even numbers or not, 78, 23, 46, 90. Q3. Find the product of 12 and 24. Q4. How many even numbers are their from 50 to 100? Related Articles: Real Numbers Imaginary Numbers Rational Number Irrational Numbers Whole Numbers Integers Even Numbers 1 to 100- FAQs 1. What are Even Numbers? Numbers which are exactly divisible by 2 are Even Numbers. Examples of even numbers are 2, 4, 6, 8, 10, etc. 2. How Many Even Numbers are Between 1 and 100?  As every other integer is even, thus between 1 and 100 there are 98 number(not including 1 and 100) and half of them must be even and half of them are odd number. Therefore there are 49 even numbers between 1 and 100. 3. How Many Even Numbers are Prime? As all even numbers has 2 as their factor, thus even numbers can't be prime numbers, but there is one exception to that as 2 is the first prime number. Thus, 2 is only even number which is prime as well. 4. Is Zero(0) an Even Number? Yes, zero is an even number, because it is divisible by 2 5. What is General Form of Even Numbers? The general form of an even number is 2n, where n is any integer. 6. Are all Even Numbers Natural Numbers? No, not all even numbers are not natural numbers there are some integers that are even numbers but not natural number such as, -2, -6, etc. all are even numbers but not natural numbers. 7. What is Smallest Even Number? The smallest even number is 2. 8. What is Average of Even Numbers 1 to 100? The average of even numbers 1 to 100 is 51. 9. What are the Even Prime Numbers from 1 to 100? Even Prime Numbers from 1 to 100 is, 2. 10. What is 0 Odd or Even? Zero(0) is an Even Number. 11. Is 1 an Even and Odd Number? 1 is an Odd Number, as it does not divisible by 2. 12. What are even numbers from 1 to 100? Even numbers from 1 to 100 include: 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100. 13. What are odd and even numbers? Odd numbers are the numbers that cannot be divided by 2, whereas even numbers are those numbers that can be exactly divided by 2. Examples of odd numbers are 3, 5, 7, 9, 11, 13, 15. Examples of even numbers are 2, 4, 6, 8, 10, 12, 14. Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now! Last Updated : 23 Nov, 2023 Like Article Save Article Previous Square Root 1 to 30 Next NCERT Solutions for Class 9 Science Chapter 12 Improvement in Food Resources ```
``` Please Login to comment... ```
``` Similar Reads If two numbers a and b are even, then prove that their sum a + b is even Count of integers in a range which have even number of odd digits and odd number of even digits How many whole numbers are there between 1 and 100? What are the whole numbers from 1 to 100? Roman Numbers 1 to 100 Prime Numbers 1 to 100 Odd Numbers 1 to 100 Sum of all even numbers in range L and R Sum of elements in range L-R where first half and second half is filled with odd and even numbers Count of all even numbers in the range [L, R] whose sum of digits is divisible by 3 Complete Tutorials What is Logarithm? - Definition, Rules and Properties Linear Algebra Maths Physics Chemistry Article Contributed By : GeeksforGeeks Vote for difficulty Current difficulty : Basic Improved By : satyam_sharmamandeepsinc16oharshghqs60 Article Tags : Maths-Class-6 Numbers Class 6 School Learning School Mathematics Practice Tags : Numbers Report Issue ```
``` ```
``` ```
``` ```
``` Courses 8k+ interested Geeks CBSE Class 12 Computer Science 91k+ interested Geeks GATE CS & IT 190k+ interested Geeks Complete Machine Learning & Data Science Program Recently Published Top 10 Android Project Ideas With Source Code Top 10 Redux Alternatives For State Management 10 Best Software Testing Tools For QA Top 10 VS Code Extensions For Data Science How to Choose the Right Backend Technology? Python For DevOps: â€ŠA Complete Guide For Beginners Top 10 Power BI Project Ideas For Data Science Top 10 VS Code Extensions For Python Django Python vs Java Full Stack Developer .right-bar-explore-more a{display: block!important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;} .right-bar-explore-more{visibility: hidden; min-height: 230px;margin: 0 0 0 auto;text-align:left;min-width:300px;max-width:300px} .right-bar-explore-more .title{text-align:left;font-size:16px;background:#445867;color:#fff;border-top-left-radius:7px;border-top-right-radius:7px;padding:5px 10px;font-family:var(--font-secondary)} .right-bar-explore-more .rightbar-sticky-ul {background:var(--gfg-grey-bg);padding:10px 20px;border-bottom-left-radius:7px;border-bottom-right-radius:7px; list-style: disc outside;margin: 0 0 24px;} .right-bar-explore-more .rightbar-sticky-ul li{line-height:2!important} .right-bar-explore-more .rightbar-sticky-ul a{font-size:15px!important;color:var(--color-black)!important;text-align:left!important} .right-bar-explore-more .rightbar-sticky-ul a:hover{text-decoration:underline;color:var(--color-gfg)!important} var rightBarExploreMoreList = `<li style="color:var(--color-black)"><a href="https://www.geeksforgeeks.org/maximum-and-minimum-in-an-array/" target="_blank" style="font-family:var(--font-primary)">Maximum and minimum of an array using minimum number of comparisons</a></li><li style="color:var(--color-black)"><a href="https://www.geeksforgeeks.org/numbers/" target="_blank" style="font-family:var(--font-primary)">What are Numbers?</a></li><li style="color:var(--color-black)"><a href="https://www.geeksforgeeks.org/bcd-or-binary-coded-decimal/" target="_blank" style="font-family:var(--font-primary)">BCD or Binary Coded Decimal</a></li><li style="color:var(--color-black)"><a href="https://www.geeksforgeeks.org/what-is-the-largest-number-in-the-world/" target="_blank" style="font-family:var(--font-primary)">What is the biggest number in the world?</a></li><li style="color:var(--color-black)"><a href="https://www.geeksforgeeks.org/eulers-totient-function/" target="_blank" style="font-family:var(--font-primary)">Euler's Totient Function</a></li>` \$(document).ready(function(){ var cardAdded = false; if(window.innerWidth >= 992 && !cardAdded ){ var lastCard = \$('#whatsNewCardContainer .card-layout:last-child').html(); \$('#whatsNewCardContainer .card-layout:last-child').hide(); \$('#secondary').prepend(`<div class='card-layout'>\${lastCard?lastCard:''}</div>`); cardAdded = true; } \$(window).resize(function(){ if(window.innerWidth >= 992 ){ if(!cardAdded){ var lastCard = \$('#whatsNewCardContainer .card-layout:last-child').html(); \$('#whatsNewCardContainer .card-layout:last-child').hide(); \$('#secondary').prepend(`<div class='card-layout'>\${lastCard?lastCard:''} </div>`); cardAdded = true; } } else{ \$('#secondary .card-layout:first-child').hide(); \$('#whatsNewCardContainer .card-layout:last-child').show(); cardAdded = false; } }); \$('#whatsNewCardContainer .card-layout-parent').css({ 'max-height': '255px', 'margin-bottom': '10px' }); \$('#whatsNewCardContainer .side--container_wscard').css({ 'padding': '25px 10px 0' }); \$('#whatsNewCardContainer .card-layout-parent > div:first-child .side--container_wscard').css({ 'padding': '2px 10px 0' }); }); .article--container_content{ align-items: unset !important; } .sideBar { position: sticky !important; } .gfg-icon_switch::after { background-position: -40px -281px !important; } .gfg-icon_transaction::after { background-position: -40px -321px !important; } .header-main__profile.selected+.mega-dropdown{ width: 225px !important; } #courses-container .course-price{ display:none; } .side--container_wscard .card-content .content .meta:empty, .practiceBannerFromPlugin{ display:none !important; } .side--container_wscard .card-content .content .meta{ display:block !important; } .side--container_wscard .card-content .content .meta p{ background-color: rgba(254, 212, 91, 0.6); font-size: 10pt; font-weight: bold; display: inline-block; color: var(--color-black); margin-top: 15px; padding: 0px 5px; } #try-it{ display:initial !important; } #try-it .try-it-div{ line-height: 34px; } #try-it .submission-count{ margin-top: 10px; } .gfg-icon_dark-mode::after { background-position: -40px -680px; } .side--container_wscard .head{ font-size: 14px !important; } .nineDot-menu, .gfg-icon_ndot{ display: none; } #text-15{ flex-direction: column; } .mtq_correct_marker, .mtq_wrong_marker{ display: none; } .sidebar_wrapper > :last-child{ margin: unset !important; margin-left: 5px !important; margin-top: 20px !important; top: 70px !important; } .darkMode-wrap{ bottom:1% !important; } #secondary .textwidget{ margin-left: auto; margin-right: 0; text-align: right; } #secondary .widget_text:last-child{ top: 70px !important; } @media(max-width:768px){ #scrollTopBtn{ display:none !important; } } ```
``` ```
``` \$(document).ready(function() { var isfollowingApiCall = false; if (\$('.follow-btn').length) { var articleRecommendedTop = \$(".article--recommended").offset().top; var articleRecommendedBottom = articleRecommendedTop + \$(".article--recommended").outerHeight(); \$(window).scroll(function() { var top_of_element = \$(".article--recommended").offset().top; var bottom_of_element = \$(".article--recommended").offset().top + \$(".article--recommended").outerHeight(); var bottom_of_screen = \$(window).scrollTop() + \$(window).innerHeight(); var top_of_screen = \$(window).scrollTop(); if ((bottom_of_screen > top_of_element && top_of_screen < bottom_of_element) || (bottom_of_screen > articleRecommendedTop && top_of_screen < articleRecommendedBottom) || (top_of_screen > articleRecommendedBottom)) { if (!isfollowingApiCall) { isfollowingApiCall = true; setTimeout(function(){ if (loginData?.isLoggedIn) { if (loginData.userName !== \$('#followAuthor').val()) { is_following(); } else { \$('.profileCard-profile-picture').css('background-color', '#E7E7E7'); } } else { \$('.follow-btn').removeClass('hideIt'); } }, 3000); } } }); } }); window.isReportArticle = false; function report_article(){ if(!loginData?.isLoggedIn){ if (\$('.header-main__wrapper').find('.header-main__signup.login-modal-btn').length) { \$('.header-main__wrapper').find('.header-main__signup.login-modal-btn').click(); } return; } if(!window.isReportArticle){ //to add loader \$('.report-loader').addClass('spinner'); jQuery('#report_modal_content').load(gfgSiteUrl+'wp-content/themes/iconic-one/report-modal.php', { PRACTICE_API_URL: practiceAPIURL, PRACTICE_URL:practiceURL },function(responseTxt, statusTxt, xhr){ if(statusTxt == "error"){ alert("Error: " + xhr.status + ": " + xhr.statusText); } }); }else{ window.scrollTo({ top: 0, behavior: 'smooth' }); \$("#report_modal_content").show(); } } .all-footer-information{ width: 100% !important;; } .footer-wrapper_links-list{ margin-block-start: 0em !important; width: 16% !important; padding-inline-start: 18px !important; } .gfg-footer .footer-wrapper_links-list li:first-child{ padding-bottom: 10px !important;; } .link-head{ margin-bottom: 0px; } @media only screen and (max-width:1340px) { .footer-wrapper_links-list{ overflow-wrap: break-word; } } @media screen and (min-width: 991px) { .all-footer-information{ padding-left:15px; } } @media only screen and (max-width:980px) { .footer-wrapper_branding-address{ padding-top: 10px; } } ```
``` A-143, 9th Floor, Sovereign Corporate Tower, Sector-136, Noida, Uttar Pradesh - 201305 CompanyAbout UsLegalCareersIn MediaContact UsAdvertise with usGFG Corporate SolutionPlacement Training ProgramApply for MentorExploreJob-A-Thon Hiring ChallengeHack-A-ThonGfG Weekly ContestOffline Classes (Delhi/NCR)DSA in JAVA/C++Master System DesignMaster CPGeeksforGeeks VideosLanguagesPythonJavaC++PHPGoLangSQLR LanguageAndroid TutorialDSAData StructuresAlgorithmsDSA for BeginnersBasic DSA ProblemsDSA RoadmapTop 100 DSA Interview ProblemsDSA Roadmap by Sandeep JainAll Cheat SheetsData Science & MLData Science With PythonData Science For BeginnerMachine Learning TutorialML Maths Data Visualisation TutorialPandas TutorialNumPy TutorialNLP TutorialDeep Learning TutorialHTML & CSSHTMLCSSBootstrapTailwind CSSSASSLESSWeb DesignPythonPython Programming ExamplesDjango TutorialPython ProjectsPython TkinterWeb ScrapingOpenCV Python TutorialPython Interview QuestionComputer ScienceGATE CS NotesOperating SystemsComputer NetworkDatabase Management SystemSoftware EngineeringDigital Logic DesignEngineering MathsDevOpsGitAWSDockerKubernetesAzureGCPDevOps RoadmapCompetitive ProgrammingTop DS or Algo for CPTop 50 TreeTop 50 GraphTop 50 ArrayTop 50 StringTop 50 DPTop 15 Websites for CPSystem DesignWhat is System DesignMonolithic and Distributed SDHigh Level Design or HLDLow Level Design or LLDCrack System Design RoundSystem Design Interview QuestionsGrokking Modern System DesignJavaScriptTypeScriptReactJSNextJSAngularJSNodeJSExpress.jsLodashWeb BrowserNCERT SolutionsClass 12Class 11Class 10Class 9Class 8Complete Study MaterialSchool SubjectsMathematicsPhysicsChemistryBiologySocial ScienceEnglish GrammarCommerceAccountancyBusiness StudiesIndian EconomicsMacroeconomicsMicroeconimicsStatistics for EconomicsManagement & Finance ManagementHR ManagamentIncome TaxFinanceEconomicsUPSC Study MaterialPolity NotesGeography NotesHistory NotesScience and Technology NotesEconomy NotesEthics NotesPrevious Year PapersSSC/ BANKINGSSC CGL SyllabusSBI PO SyllabusSBI Clerk SyllabusIBPS PO SyllabusIBPS Clerk SyllabusSSC CGL Practice PapersCollegesIndian Colleges Admission & Campus ExperiencesTop Engineering CollegesTop BCA CollegesTop MBA CollegesTop Architecture CollegeChoose College For GraduationCompaniesIT CompaniesSoftware Development CompaniesArtificial Intelligence(AI) CompaniesCyberSecurity CompaniesService Based CompaniesProduct Based CompaniesPSUs for CS EngineersPreparation CornerCompany Wise PreparationPreparation for SDEExperienced InterviewsInternship InterviewsCompetitive ProgrammingAptitude PreparationPuzzlesExamsJEE MainsJEE AdvancedGATE CSNEETUGC NETMore Tutorials Software DevelopmentSoftware TestingProduct ManagementSAPSEOLinuxExcelWrite & EarnWrite an ArticleImprove an ArticlePick Topics to WriteShare your ExperiencesInternships @GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy if(post_slug.includes('premium-plans-payment/') || post_slug.includes('premium-plans/')){ \$('.darkMode-wrap').remove(); \$('.toggle-darkMode').remove(); } Improvement Please go through our recently updated Improvement Guidelines before submitting any improvements. This article is being improved by another user right now. You can suggest the changes for now and it will be under the article's discussion tab. You will be notified via email once the article is available for improvement. Thank you for your valuable feedback! Please go through our recently updated Improvement Guidelines before submitting any improvements. Suggest Changes Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal. Create Improvement Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all. Suggest Changes Suggestion[CharLimit:2000] Create Improvement jQuery('.improve-header-sec-child').on('click', function(){ jQuery('.improve-modal--overlay').hide(); \$('.improve-modal--suggestion').hide(); \$('.improvement-reason-modal').hide(); }); \$('.suggest-change_wrapper, .locked-status--impove-modal .improve-bottom-btn').on('click',function(){ // when suggest changes option is clicked \$('#suggestion-section-textarea').val(""); \$('.suggest-bottom-btn').html("Suggest changes"); \$('.improve-modal--improvement').hide(); \$('.improve-modal--suggestion').show(); }); \$('.create-improvement_wrapper').on('click',function(){ // when create improvement option clicked then improvement reason will be shown \$('body').append('<div class="spinner-loading-overlay"></div>'); \$('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, check: true }), success:function(result) { jQuery.ajax({ url: "https://comment.geeksforgeeks.org/api/improvement/post/status/", type: "GET", dataType: 'json', xhrFields: { withCredentials: true }, data: { 'status': 'approved', 'post_id': `gfg_post_\${post_id}`, 'order_by': 'asc', }, success: function (result) { \$('.spinner-loading-overlay:eq(0)').remove(); var commentArray = result['data']['comments']; if(commentArray === null || commentArray.length === 0) { // when no reason is availaible then user will redirected directly make the improvment. // call to api create-improvement-post \$('body').append('<div class="spinner-loading-overlay"></div>'); \$('.spinner-loading-overlay').show(); jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, }), success:function(result) { \$('.spinner-loading-overlay:eq(0)').remove(); \$('.improve-modal--overlay').hide(); \$('.unlocked-status--improve-modal-content').css("display","none"); \$('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `\${result.id}` + '/', '_blank'); \$('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { \$('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ \$('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`\${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); \$('.locked-status--impove-modal').css("display","block"); \$('.unlocked-status--improve-modal-content').css("display","none"); \$('.improve-modal--improvement').attr("status","locked"); \$('.improvement-reason-modal').hide(); } }, }); return; } var improvement_reason_html = ""; for(var comment of commentArray) { // loop creating improvement reason list markup var comment_id = comment['comment_id']; var comment_text = comment['text']; improvement_reason_html += `<div class="checkbox_wrapper"> <span><input type="checkbox" id=\${comment_id} class="reason-checkbox"></span> <span class="reason-content">\${comment_text}</span> </div>`; } improvement_reason_html += `<div class="checkbox_wrapper"> <span><input type="checkbox" id="none" class="reason-checkbox"></span> <span class="reason-content"><p>My reason is not listed</p></span> </div>`; \$('.improvement-reasons_wrapper').html(improvement_reason_html); \$('.improvement-bottom-btn').html("Create Improvement"); \$('.improve-modal--improvement').hide(); \$('.improvement-reason-modal').show(); disable_create_improvement_button(); \$('.reason-checkbox').change(function(){ // to enable and disable create improvement button var checkedCount = \$('input[type="checkbox"]:checked').length; if(checkedCount > 0) enable_create_improvement_button(); else disable_create_improvement_button(); }) }, error: function(e){ \$('.spinner-loading-overlay:eq(0)').remove(); // stop loader when ajax failed; }, }); }, error:function(e) { \$('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ \$('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`\${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); \$('.locked-status--impove-modal').css("display","block"); \$('.unlocked-status--improve-modal-content').css("display","none"); \$('.improve-modal--improvement').attr("status","locked"); \$('.improvement-reason-modal').hide(); } }, }); }); \$('.left-arrow-icon_wrapper').on('click',function(){ if(\$('.improve-modal--suggestion').is(":visible")) \$('.improve-modal--suggestion').hide(); else{ disable_create_improvement_button(); \$('.improvement-reason-modal').hide(); } \$('.improve-modal--improvement').show(); }); jQuery('.suggest-bottom-btn').on('click', function(){ var suggest_val = \$.trim(\$("#suggestion-section-textarea").val()); var error_msg = false; if(suggest_val != ""){ if(suggest_val.length <= 2000){ jQuery('body').append('<div class="spinner-loading-overlay"></div>'); jQuery('.spinner-loading-overlay').show(); jQuery.ajax({ type:'post', url: "https://comment.geeksforgeeks.org/api/comment/", xhrFields: { withCredentials: true }, crossDomain: true, contentType:'application/json', data: JSON.stringify({ "ancestry": "", "domain": "gfg", "post_id": `gfg_post_\${post_id}`, "post_title": `\${post_title}`, "post_url": `\${post_slug}`, "tags": { "public_tags": ["improvement"], "private_tags": [`gfg_post_\${post_id}`] }, "text":`<p>\${suggest_val}</p>` }), success:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-section-textarea').val(""); jQuery('.suggest-bottom-btn').html("Sent <samp style='margin-left: 2px;'><i class='gfg-icon suggest-cross-icon'></i></samp>"); setTimeout(() => { jQuery('.improve-modal--overlay').hide(); \$('.improve-modal--suggestion').hide(); \$('.discuss').trigger('click'); if(\$('#discuss-iframe').length == 1){ \$('#discuss-iframe').remove(); loadComments(); } }, 1000); }, error:function(data) { jQuery('.spinner-loading-overlay:eq(0)').remove(); jQuery('#suggestion-modal-alert').html("Something went wrong."); jQuery('#suggestion-modal-alert').show(); error_msg = true; } }); } else{ jQuery('#suggestion-modal-alert').html("Character limit exceeded."); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } } else{ jQuery('#suggestion-modal-alert').html("Enter valid input."); jQuery('#suggestion-modal-alert').show(); jQuery('#suggestion-section-textarea').focus(); error_msg = true; } if(error_msg){ setTimeout(() => { jQuery('#suggestion-section-textarea').focus(); jQuery('#suggestion-modal-alert').hide(); }, 3000); } }) \$('.improvement-bottom-btn.create-improvement-btn').click(function() { //create improvement button is clicked \$('body').append('<div class="spinner-loading-overlay"></div>'); \$('.spinner-loading-overlay').show(); disable_create_improvement_button(); // get checked options var suggestionArray = new Array(); \$('.reason-checkbox:checked').each(function() { var id = \$(this).attr('id'); if(id !== 'none'){ suggestionArray.push(id); } }); // send this option via create-improvement-post api jQuery.ajax({ url: writeApiUrl + 'create-improvement-post/?v=1', type: "POST", contentType: 'application/json; charset=utf-8', dataType: 'json', xhrFields: { withCredentials: true }, data: JSON.stringify({ gfg_id: post_id, suggestion_ids: suggestionArray }), success:function(result) { \$('.spinner-loading-overlay:eq(0)').remove(); \$('.improve-modal--overlay').hide(); \$('.improvement-reason-modal').hide(); \$('.create-improvement-redirection-to-write').attr('href',writeUrl + 'improve-post/' + `\${result.id}` + '/', '_blank'); \$('.create-improvement-redirection-to-write')[0].click(); }, error:function(e) { \$('.spinner-loading-overlay:eq(0)').remove(); var result = e.responseJSON; if(result.detail.non_field_errors.length){ \$('.improve-modal--improve-content .improve-modal--improve-content-modified').text(`\${result.detail.non_field_errors}.`); jQuery('.improve-modal--overlay').show(); jQuery('.improve-modal--improvement').show(); \$('.locked-status--impove-modal').css("display","block"); \$('.unlocked-status--improve-modal-content').css("display","none"); \$('.improve-modal--improvement').attr("status","locked"); \$('.improvement-reason-modal').hide(); } }, }); }); function enable_create_improvement_button(){ \$('.improvement-reason-modal .improvement-bottom-btn').prop('disabled', false); \$('.improvement-reason-modal .improvement-bottom-btn').css({'background-color':'#2F8D46','color': '#FFFFFF'}); } function disable_create_improvement_button(){ \$('.improvement-reason-modal .improvement-bottom-btn').prop('disabled', true); if(\$('body').attr('data-dark-mode') === 'true') \$('.improvement-reason-modal .improvement-bottom-btn').css({'background-color':'#3C3C3C','color': '#FFFFFFB3'}); else \$('.improvement-reason-modal .improvement-bottom-btn').css({'background-color':'#EDEDED','color':'#8F8F8F'}); } var AdblockPlus = new function() { this.detect = function(px, callback) { var detected = false; var checksRemain = 2; var error1 = false; var error2 = false; if (typeof callback != "function") return; px += "?ch=*&rn=*"; function beforeCheck(callback, timeout) { if (checksRemain == 0 || timeout > 1E3) callback(checksRemain == 0 && detected); else setTimeout(function() { beforeCheck(callback, timeout * 2) }, timeout * 2) } function checkImages() { if (--checksRemain) return; detected = !error1 && error2 } var random = Math.random() * 11; var img1 = new Image; img1.onload = checkImages; img1.onerror = function() { error1 = true; checkImages() }; img1.src = px.replace(/\*/, 1).replace(/\*/, random); var img2 = new Image; img2.onload = checkImages; img2.onerror = function() { error2 = true; checkImages() }; img2.src = px.replace(/\*/, 2).replace(/\*/, random); beforeCheck(callback, 250) } }; /* AdblockPlus.detect("https://cdnads.geeksforgeeks.org/res/px.gif", function(abp){ window.googletag = window.googletag || {cmd: []}; window.abp=abp; var elms = [...document.querySelectorAll('div[id^=_GFG_ABP_]')]; const units=elms.map(elem=>elem.id) if(abp) { for(let curr_unit of units) { const iframe = document.createElement('iframe'); iframe.setAttribute('src',"https://aa.geeksforgeeks.org/iframe.html?code="+curr_unit.substr(1)) const elem = document.getElementById(curr_unit) const div = document.createElement('div'); div.setAttribute('id',curr_unit.substr(1)) let sizes = curr_unit.split("_"); sizes = sizes.filter(val => val.includes('x')); let [width, height] = sizes[0].split("x"); iframe.style.width = `\${+width+20}px` iframe.style.height = `\${+height+20}px` if(elem) { elem.appendChild(iframe); } } var gfgAdDivs = [...document.querySelectorAll('div[id^=GFG_AD_]')]; gfgAdDivs.forEach(gfgDiv => document.getElementById(gfgDiv.id).removeAttribute("style")); jQuery('#secondary .widget_text:last-child').css({"position": "unset"}); } });*/ AdblockPlus.detect("https://cdnads.geeksforgeeks.org/res/px.gif", function(abp){ window.googletag = window.googletag || {cmd: []}; window.abp=abp; var elms = [...document.querySelectorAll('div[id^=_GFG_ABP_]')]; //const units=elms.map(elem=>elem.id) const units = elms .filter(elem => !(window.innerWidth < 1500 && elem.id === "_GFG_ABP_Incontent_728x90")) .map(elem => elem.id); if(abp) { isAdBlockerPresent = true; for(let curr_unit of units) { const iframe = document.createElement('iframe'); iframe.addEventListener("load", () => { iframe.contentWindow.postMessage(JSON.stringify({host: window.location.host,category: window.arrPostCatName,parentWidth: window.innerWidth}),'https://aa.geeksforgeeks.org'); }); iframe.setAttribute('src',"https://aa.geeksforgeeks.org/iframe.html?code="+curr_unit.substr(1)) const elem = document.getElementById(curr_unit) const div = document.createElement('div'); div.setAttribute('id',curr_unit.substr(1)) let sizes = curr_unit.split("_"); sizes = sizes.filter(val => val.includes('x')); let [width, height] = sizes[0].split("x"); iframe.style.width = `\${+width+20}px` iframe.style.height = `\${+height+20}px` if(elem) { elem.appendChild(iframe); } } var gfgAdDivs = [...document.querySelectorAll('div[id^=GFG_AD_]')]; gfgAdDivs.forEach(gfgDiv => document.getElementById(gfgDiv.id).removeAttribute("style")); jQuery('#secondary .widget_text:last-child').css({"position": "unset"}); } else{ try { var isAdblockEnabled = t => fetch( new Request('https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', { method: 'HEAD', mode: 'no-cors' }) ).catch(t); isAdblockEnabled(() => { // here goes modal pop-up code isAdBlockerPresent = true; }); } catch (err) {console.log(err);} } }); function closeAdBlockPopupModal(){ const modal = document.getElementById("adBlockerModal"); \$('body').removeClass('body-for-ad-blocker'); \$('#adBlockerModal').remove() localStorage.setItem('gfgAdBlockPopup',new Date()) } function showAdblockerModal(){ let currTime = new Date(); let lastTime = new Date(localStorage.getItem('gfgAdBlockPopup')); if(((currTime-lastTime)/(1000*60*60))<1) { return; } const adBlockerModal = `<div id="adBlockerModal" class="ad-blocker-modal"> <div id="ad-blocker-modal-overlay"> <div id="ad-blocker-outer-div"> <div id="ad-blocker-div"> <p id="ad-blocker-div-warning" style="margin-bottom: 30px;">It seems that you are using an ad blocker.<br><span style="font-size: 20px;">Please disable it to support us!</span></p> <div id="ad-blocker-div-btns"> <button id="ad-blocker-div-button1" onclick="handleAdBlockerClick('disabled')"> I disabled my ad blocker </button> <button id="ad-blocker-div-button2" onclick="handleAdBlockerClick('info')"> Show Me How </button> </div> <div id="ad-blocker-div-continue-btn-div"> <a id="ad-blocker-div-continue-btn" href="#" onclick="closeAdBlockPopupModal()">Continue without supporting &#128546;</a> </div> </div> <div id="ad-blocker-info-div" style="display:none;"> <div id="ad-blocker-info-div-continue-btn-div"> <a id="ad-blocker-info-div-continue-btn" href="">I disabled my ad blocker</a> </div> <div id="ad-blocker-info-div-instructions-div"> <p id="ad-blocker-info-div-instructions-para">Select from the following icons for instructions on how to add us to your safe sites list.</p> </div> <div id="ad-blocker-info-div-icons-div"> <div class="ad-blocker-info-div-icons-circle-div" id="ad-blocker-info-div-icons-0" onclick="handleAdBlockerIconClick('0')"> </div> <div class="ad-blocker-info-div-icons-circle-div" id="ad-blocker-info-div-icons-1" onclick="handleAdBlockerIconClick('1')"> </div> <div class="ad-blocker-info-div-icons-circle-div" id="ad-blocker-info-div-icons-2" onclick="handleAdBlockerIconClick('2')"> </div> <div class="ad-blocker-info-div-icons-circle-div" id="ad-blocker-info-div-icons-3" onclick="handleAdBlockerIconClick('3')"> </div> </div> <div id="ad-blocker-info-div-gif-div"> <video id="ad-blocker-info-div-gif" autoplay muted loop> <source id="ad-blocker-info-div-gif-src" src="https://i.piano.io/managedservices/adblock-sources/videos/chrome-adblock.mp4" type="video/mp4"> </video> </div> <div id="ad-blocker-info-div-steps-div"> <ol id="ad-blocker-info-div-steps-ul"> <li class="ad-blocker-info-div-steps-li">Click on the <span id="ad-blocker-info-div-name-span">uBlock</span> icon at the top right corner of your browser.</li> <li class="ad-blocker-info-div-steps-li">Click Enabled on this site until the text reads Disabled on this site.</li> <li class="ad-blocker-info-div-steps-li">Click Done below to close this window and refresh the page.</li> </ol> </div> </div> </div> </div> </div>`; \$('body').append(adBlockerModal); \$('body').addClass('body-for-ad-blocker'); const modal = document.getElementById("adBlockerModal"); modal.style.display = "block"; } function handleAdBlockerClick(type){ if(type == 'disabled'){ window.location.reload(); } else if(type == 'info'){ document.getElementById("ad-blocker-div").style.display = "none"; document.getElementById("ad-blocker-info-div").style.display = "flex"; handleAdBlockerIconClick(0); } } var lastSelected= null; //Mapping of name and video URL with the index. const adBlockerVideoMap = [ ['Ad Block Plus','https://media.geeksforgeeks.org/auth-dashboard-uploads/abp-blocker-min.mp4'], ['Ad Block','https://media.geeksforgeeks.org/auth-dashboard-uploads/Ad-block-min.mp4'], ['uBlock Origin','https://media.geeksforgeeks.org/auth-dashboard-uploads/ub-blocke-min.mp4'], ['uBlock','https://media.geeksforgeeks.org/auth-dashboard-uploads/U-blocker-min.mp4'], ] function handleAdBlockerIconClick(currSelected){ const videocontainer = document.getElementById('ad-blocker-info-div-gif'); const videosource = document.getElementById('ad-blocker-info-div-gif-src'); if(lastSelected != null){ document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.backgroundColor = "white"; document.getElementById("ad-blocker-info-div-icons-"+lastSelected).style.borderColor = "#D6D6D6"; } document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.backgroundColor = "#D9D9D9"; document.getElementById("ad-blocker-info-div-icons-"+currSelected).style.borderColor = "#848484"; document.getElementById('ad-blocker-info-div-name-span').innerHTML = adBlockerVideoMap[currSelected][0] videocontainer.pause(); videosource.setAttribute('src', adBlockerVideoMap[currSelected][1]); videocontainer.load(); videocontainer.play(); lastSelected = currSelected; } if(window.innerWidth <= 500){ var googletag = googletag || {}; googletag.cmd = googletag.cmd || []; // GPT ad slots var interstitialSlot; googletag.cmd.push(function () { // Define a web interstitial ad slot. interstitialSlot = googletag.defineOutOfPageSlot( '/27823234/GFG_Desktop_Interstitial', googletag.enums.OutOfPageFormat.INTERSTITIAL); // Slot returns null if the page or device does not support interstitials. if (interstitialSlot) { interstitialSlot.addService(googletag.pubads()); } // Enable SRA and services. googletag.pubads().enableSingleRequest(); googletag.enableServices(); googletag.display(interstitialSlot); googletag.pubads().refresh([interstitialSlot]); }); } function geekWeek2023Optimizations(userDemographicInfo) { var isIndia = (userDemographicInfo['country_code'] == 'IN')?true:false; // Header Sub Header changes for Nov 2023 const istTimeZone = 'Asia/Kolkata'; // Geek Week Stuff var isSale = false; var saleLastDays = false; var rightBarScratchWinBtn = false; const startDate = new Date('2023-11-24T11:59:59'); // Geek Week Start Date const endDate = new Date('2023-11-26T11:59:59'); // Geek Week End Date const saleLastDaysThresholdDate = new Date('2023-11-25T11:59:59'); // Geek Week Last Day Threshold Date const rightBarScratchWinBtnThresholdDate = new Date('2023-11-24T11:59:59'); // Current Date in IST const dateToCheck = new Date(); dateToCheck.toLocaleString('en-US', { timeZone: istTimeZone }); // Check if the date is within the range of Geek Week October 2023 if (dateToCheck >= startDate && dateToCheck <= endDate) { isSale = true; } // Check if it's the last day of Geek Week October 2023 if (dateToCheck >= saleLastDaysThresholdDate && dateToCheck <= endDate) { saleLastDays = true; } if (dateToCheck >= rightBarScratchWinBtnThresholdDate && dateToCheck <= endDate) { rightBarScratchWinBtn = true; } // Executing the code only if it's Geek Week (14th Oct 2023 - 21st Oct 2023) if(isSale) { // Defining the variables for colour, CTA links and CTA texts var gfgHomePageCourseSectionBgImageUrl = 'https://media.geeksforgeeks.org/auth-dashboard-uploads/sale-bg-3-min.png'; var gfgHomePageSearchBarChipsColour = '#fff'; var gfgHomePageSearchBarChipsBgColour = '#0096d1'; var gfgHomePageCoursesSectionCardsText = "30% Off + Extra Cashback"; var gfgHomePageCoursesSectionDiscountBgColour = '#ffd217'; var gfgHomePageCoursesSectionDiscountColour = '#404040'; var gfgHomePageCoursesSectionDiscountBorderColour = '#ffd217'; var gfgHomePageCoursesDropdownMenuPillText = "SALE"; var gfgSaleCampaignUrl = 'https://www.geeksforgeeks.org/courses'; var gfgSubHeaderCTASaleNormalDaysBgColour = '#8366ac'; var gfgSubHeaderCTASaleNormalDaysColour = '#fff'; var gfgSubHeaderCTASaleNormalDaysText = 'Courses @30% Off'; var gfgSubHeader24hrTimerBgColour = '#f05721'; var gfgSubHeader24hrTimerColour = '#fff'; var gfgSubHeader24hrTimerText = "Sale Ends In"; var gfgRightBarCourseCardBtnText = " Flat 30% Off"; var gfgRightBarBtnText = "Spin & Win!"; var gfgSaleCoursesBannerImageUrl = "https://media.geeksforgeeks.org/auth-dashboard-uploads/In-article-Ad-02.gif"; var gfgArticlePageCoursesTabCardsText = "30% Off + Extra Cashback"; var gfgSalePracticeBannerImageUrl = "https://media.geeksforgeeks.org/auth-dashboard-uploads/In-article-Ad-01.gif"; var gfgHomePageFloatingButtonBgColor = '#f9e065'; var gfgHomePageFloatingButtonColor = '#000'; var gfgHomePageFloatingButtonText = 'Black Friday Sale'; var gfgHomePageFloatingButtonImgUrl = 'https://media.geeksforgeeks.org/auth-dashboard-uploads/BFS.gif'; var gfgHomePageFloatingButtonBShadow = '0 0 12px rgba(251,236,93)'; /* JS to change the following :- 1. Header chip's background colour which are shown below search bar on Home page 2. To add sale background image behind courses section */ isElementInDOM("head")?document.querySelector("head").insertAdjacentHTML('beforeend', `<style> div.gfg_home_page_course_outer_height { background-image : url(\${gfgHomePageCourseSectionBgImageUrl}); } button.gfg_home_page_chips_button{ background-color: \${gfgHomePageSearchBarChipsBgColour} !important; color: \${gfgHomePageSearchBarChipsColour} !important; font-weight: bolder; } </style>`):""; /* JS to change the following :- 1. Upto x % discount div in place of course rating div for each course card shown on home page */ isElementInDOM("div.gfg_home_page_course_card_divider>div:nth-of-type(1)>div:nth-of-type(2)",true)?document.querySelectorAll('div.gfg_home_page_course_card_divider>div:nth-of-type(1)>div:nth-of-type(2)').forEach(function (node, index) { node.outerHTML = `<div class="ant-col"><div class="ant-row"><div class="gfg_home_page_course_card_rating" style="background: \${gfgHomePageCoursesSectionDiscountBgColour};border: 1px solid \${gfgHomePageCoursesSectionDiscountBorderColour} !important;"><span class="gfg_home_page_course_rating_val" style="padding-left: 4px;color: \${gfgHomePageCoursesSectionDiscountColour} !important;font-weight: bold;">\${gfgHomePageCoursesSectionCardsText}</span></div></div></div>`; }):""; isElementInDOM("div.gfg_home_page_course_card_divider>div:nth-of-type(3)",true)?document.querySelectorAll('div.gfg_home_page_course_card_divider>div:nth-of-type(3)').forEach(function (node, index) { node.style.paddingTop = '10px'; }):""; /* JS to change the following :- 1. Add Sale ends in timer in subheader (Middle) 2. Add normal Subheader CTA (Middle) */ // Timer div if(saleLastDays) { isElementInDOM("#hslider>li:nth-of-type(1)")?document.querySelector("#hslider>li:nth-of-type(1)").insertAdjacentHTML('beforebegin', `<li style="background: \${gfgSubHeader24hrTimerBgColour};"><style>span#timer #hours { font-size: 18px; color: \${gfgSubHeader24hrTimerColour}; font-weight: bold;} span#timer #minutes { font-size: 18px; color: \${gfgSubHeader24hrTimerColour}; font-weight: bold;} span#timer #seconds { font-size: 14px; color: \${gfgSubHeader24hrTimerColour}; font-weight: bold;}</style><a href="\${gfgSaleCampaignUrl}?itm_source=geeksforgeeks&itm_medium=sub_header&itm_campaign=bf2023" style="color: \${gfgSubHeader24hrTimerColour} !important;font-weight: bolder;">\${gfgSubHeader24hrTimerText} <span id="timer"><span id="hours"></span><span id="minutes"></span><span id="seconds"></span></span></a></li>`):""; function makeTimer(saleEndDate) { var end_time = new Date(saleEndDate); end_time = (Date.parse(end_time) / 1000); var now = new Date(); now = (Date.parse(now) / 1000); var time_left = end_time - now; var days = Math.floor(time_left / 86400); var hours = Math.floor((time_left - (days * 86400)) / 3600); var orig_hours = Math.floor(time_left / 3600); var minutes = Math.floor((time_left - (days * 86400) - (hours * 3600 )) / 60); var seconds = Math.floor((time_left - (days * 86400) - (hours * 3600) - (minutes * 60))); if (orig_hours < "10") { orig_hours = "0" + orig_hours; } if (minutes < "10") { minutes = "0" + minutes; } if (seconds < "10") { seconds = "0" + seconds; } document.getElementById("hours").innerHTML = orig_hours + " : "; document.getElementById("minutes").innerHTML = minutes + " : "; document.getElementById("seconds").innerHTML = seconds; } setInterval(function() { makeTimer(endDate); }, 1000); } else { // Normal scenario Subheader CTA isElementInDOM("#hslider>li:nth-of-type("+Math.ceil(document.querySelectorAll('#hslider>li').length/3)+")")?document.querySelector("#hslider>li:nth-of-type("+Math.ceil(document.querySelectorAll('#hslider>li').length/3)+")").insertAdjacentHTML('beforebegin', `<li style="background-color: \${gfgSubHeaderCTASaleNormalDaysBgColour};"><a href="\${gfgSaleCampaignUrl}?itm_source=geeksforgeeks&itm_medium=sub_header&itm_campaign=bf2023" style="font-weight: bold;color: \${gfgSubHeaderCTASaleNormalDaysColour} !important;">\${gfgSubHeaderCTASaleNormalDaysText}</a></li>`):""; } /* JS to add x% off tooltip over top of 'Courses' list item in header */ if(document.querySelector('ul.header-main__list>li:nth-of-type(1) > span').innerText.trim()=='Courses'){ isElementInDOM('ul.header-main__list>li:nth-of-type(1) > span')?document.querySelector('ul.header-main__list>li:nth-of-type(1) > span').outerHTML = `<span>Courses&nbsp; <span style="background: 0% 0% no-repeat padding-box padding-box #ffd217; border-radius: 4px; font-size: 12px; color: rgb(0, 0, 0); float: right; padding: 2px 5px;position: absolute;top: -15px;right: -25px;">\${gfgHomePageCoursesDropdownMenuPillText}</span></span>`:""; } /* JS to add the following :- 1. Courses tab promo banner 2. Practice tab promo banner 3. Courses tab hearbeat dot */ // Courses tab heartbeat dot isElementInDOM('#courses-tab-main>#nav_tab_courses')?document.querySelector('#courses-tab-main>#nav_tab_courses').style.position = "relative":""; isElementInDOM('#courses-tab-main>#nav_tab_courses>span')?document.querySelector('#courses-tab-main>#nav_tab_courses>span').insertAdjacentHTML('beforebegin',`<style>#darkMode-wrap-red-dot{animation: pulse-animation 1.3s infinite;}@keyframes pulse-animation{0%{box-shadow: 0 0 0 0px rgba(249, 179, 0, 0.5);}100%{box-shadow: 0 0 0 10px rgba(249, 179, 0, 0);}}</style><div id="darkMode-wrap-red-dot" style="height: 10px;width: 10px;background-color: #F9B300;border-radius:50%;position:absolute;top: -1px;right: -10px;"></div>`):""; // Courses tab banner image isElementInDOM('#courses-tab-main div.nav_tab.courses')?document.querySelector('#courses-tab-main div.nav_tab.courses').addEventListener('click', event => { !isElementInDOM("#courses_nav_tab_content .saleBannerImage")?setTimeout(function(){isElementInDOM("#courses_nav_tab_content > #courses-heading")?document.querySelector("#courses_nav_tab_content > #courses-heading").insertAdjacentHTML('beforebegin', `<a target="_blank" href="\${gfgSaleCampaignUrl}?itm_source=geeksforgeeks&amp;itm_medium=courses_tab&amp;itm_campaign=bf2023" class="saleBannerImage"><div style="cursor:pointer;margin-top: 15px;text-align: center;" class="problems-promotional_banner"><img class="no-zoom-in-cursor" alt="python-offline-classes" src="\${gfgSaleCoursesBannerImageUrl}" style="width: 100%;"></div></a>`):""}, 2000):""; }):""; // Courses tab each course card discount % off isElementInDOM('#courses-tab-main div.nav_tab.courses')?document.querySelector('#courses-tab-main div.nav_tab.courses').addEventListener('click', event => { setTimeout(function(){isElementInDOM("#courses_nav_tab_content > #courses-container .courses-main .course-content .course-meta .btn-main a")?document.querySelectorAll("#courses_nav_tab_content > #courses-container .courses-main .course-content .course-meta .btn-main a").forEach(function (node, index) { node.innerHTML = `<span class="explore-course-btn" style="background:linear-gradient(106deg, #413d52 20%, #45274d 100%);">\${gfgArticlePageCoursesTabCardsText}</span>`; }):""}, 2000); }):""; // Courses tab practice image isElementInDOM('#practice-tab-main div.nav_tab.practice')?document.querySelector('#practice-tab-main div.nav_tab.practice').addEventListener('click', event => { !isElementInDOM("#practice-tab-content .saleBannerImage")?setTimeout(function(){isElementInDOM("#practice-tab-content > #curatedlisttitle")?document.querySelector("#practice-tab-content > #curatedlisttitle").insertAdjacentHTML('beforebegin', `<a target="_blank" href="\${gfgSaleCampaignUrl}?itm_source=geeksforgeeks&amp;itm_medium=prac_tab&amp;itm_campaign=bf2023" class="saleBannerImage"><div style="cursor:pointer;margin-top: 15px; margin-bottom:15px; text-align: center;" class="problems-promotional_banner"><img class="no-zoom-in-cursor" alt="python-offline-classes" src="\${gfgSalePracticeBannerImageUrl}" style="width: 100%;"></div>`):""}, 2000):""; }):""; // Right bar courses cards discount # off isElementInDOM('.whats-new-section .explore-course',true)?document.querySelectorAll('.whats-new-section .explore-course').forEach(function (node, index) { node.innerHTML = gfgRightBarCourseCardBtnText; node.style.cssText = ` background: linear-gradient(106deg, #413d52 20%, #45274d 100%);; color: #fff; border-color: #45274d; ` }):""; // Floating Button Black Friday Sale Changes setTimeout(() => { isElementInDOM("a.nudge_container")?(document.querySelector("a.nudge_container").outerHTML = `<a class="nudge_container nudge_container_small border_animation_fix" href="\${gfgSaleCampaignUrl}?itm_source=geeksforgeeks&itm_medium=floating_button&itm_campaign=bf2023" target="_blank" style="padding-left:12px; background: \${gfgHomePageFloatingButtonBgColor};"><div class="shimmer"></div><img loading="lazy" src="\${gfgHomePageFloatingButtonImgUrl}" alt="Black Friday Sale"><span style="margin:0px; font-weight:bold; color:\${gfgHomePageFloatingButtonColor};">\${gfgHomePageFloatingButtonText}</span></a>`, document.querySelector("a.nudge_container.nudge_container_small.border_animation_fix").style.boxShadow = gfgHomePageFloatingButtonBShadow ):""; }, 10); if(rightBarScratchWinBtn) { isElementInDOM('.whats-new-section')?\$('.whats-new-section').css('min-height','360px'):""; isElementInDOM('.whats-new-section div.heading')?document.querySelector('.whats-new-section div.heading').insertAdjacentHTML('beforebegin',`<div class="heading" style="background: linear-gradient(106deg, #f05721 20%, rgb(255, 146, 61) 100%); border-radius: 10px; box-shadow: 0 0 12px rgba(253,63,67,.36);margin: 0 auto 10px 10px; width: 270px;"><div class="def-title_wrap" style="margin: 0 auto;"><div class="title" style="font-size: 15pt !important;margin-top:10px;"><a class="" href="\${gfgSaleCampaignUrl}?show_wheel=true&itm_source=geeksforgeeks&itm_medium=rightbar_btn&itm_campaign=bf2023" target="_blank" title="Scratch and Win" style="color: #fff !important;"><span style="color: #fff !important;letter-spacing: 1px;">\${gfgRightBarBtnText}<img src="https://media.geeksforgeeks.org/img-practice/prod/courses/1/Web/Other/Fab%20icon%20(1)_1697541057.svg" alt="wheel" style="width: 35px;vertical-align: middle;position: relative;top: -3px;"></span></a></div></div></div>`):""; isElementInDOM('.whats-new-section-gblog div.gblog-heading')?document.querySelector('.whats-new-section-gblog div.gblog-heading').insertAdjacentHTML('beforebegin',`<div class="heading" style="background: linear-gradient(106deg, #f05721 20%, rgb(255, 146, 61) 100%); border-radius: 10px; box-shadow: 0 0 12px rgba(253,63,67,.36);margin: 0 auto 10px 10px; width: 270px;"><div class="def-title_wrap" style="margin: 0 auto;"><div class="title" style="font-size: 15pt !important;margin-top:10px;"><a class="" href="\${gfgSaleCampaignUrl}?show_wheel=true&itm_source=geeksforgeeks&itm_medium=rightbar_btn&itm_campaign=bf2023" target="_blank" title="Scratch and Win" style="color: #fff !important;"><span style="color: #fff !important;letter-spacing: 1px;">\${gfgRightBarBtnText}<img src="https://media.geeksforgeeks.org/img-practice/prod/courses/1/Web/Other/Fab%20icon%20(1)_1697541057.svg" alt="wheel" style="width: 35px;vertical-align: middle;position: relative;top: -3px;"></span></a></div></div></div>`):""; } } var novOptimizeChanges = false; var isContest = false; const optimizeNov23ChangesStartDate = new Date('2023-11-01T00:00:00'); const optimizeNov23ChangesEndDate = new Date('2023-11-30T23:59:59'); const optimizeNov23ContestEndDate = new Date('2023-11-10T20:00:00'); const optimizeNov23ContestFresherEndDate = new Date('2023-11-21T20:00:00'); const coursePromotionCities = JSON.parse(`{"GFG_CLASSROOM_PROGRAM_CITIES":{"NCR":["Noida","Greater Noida","Gurgaon","Ghaziabad","Faridabad","Delhi"],"NON_NCR":["Bengaluru"]},"MERN_CLASSROOM_PROGRAM_CITIES":["Pune"]}`); // Check if the date is in month of Nov 2023 if (dateToCheck >= optimizeNov23ChangesStartDate && dateToCheck <= optimizeNov23ChangesEndDate) { novOptimizeChanges = true; } // Check for Job-A-Thon Nov 10 2023 if(dateToCheck >= optimizeNov23ChangesStartDate && dateToCheck <= optimizeNov23ContestEndDate) { isContest = true; } if((novOptimizeChanges == true) && (isSale == false) && (isIndia == true)) { // Header Subheader changes for city being in NCR if((coursePromotionCities.GFG_CLASSROOM_PROGRAM_CITIES.NCR).includes((userDemographicInfo.city_name).trim()) || (coursePromotionCities.GFG_CLASSROOM_PROGRAM_CITIES.NON_NCR).includes((userDemographicInfo.city_name).trim())) { if((coursePromotionCities.GFG_CLASSROOM_PROGRAM_CITIES.NCR).includes((userDemographicInfo.city_name).trim())) { gfgOptimizeNov23HeaderSubHeaderText = 'GfG Classroom Program'; gfgOptimizeNov23Url = 'https://www.geeksforgeeks.org/courses/category/all?courseType=offline&courseFeeType=all&itm_source=geeksforgeeks&itm_medium=header&itm_campaign=courses'; isElementInDOM('ul.header-main__list>li:nth-of-type(1) > ul.mega-dropdown > li:nth-of-type(1)')? (document.querySelector('ul.header-main__list>li:nth-of-type(1) > span').innerText.trim()=='Courses') ? document.querySelector('ul.header-main__list>li:nth-of-type(1) > ul.mega-dropdown > li:nth-of-type(1)').insertAdjacentHTML('beforebegin',`<li class="mega-dropdown__list-item" data-child="true" aria-expanded="false" data-expandable="false"><a href="\${gfgOptimizeNov23Url}" target="_self">\${gfgOptimizeNov23HeaderSubHeaderText}</a></li>`):"":""; isElementInDOM("#hslider>li:nth-of-type(1)")?document.querySelector("#hslider>li:nth-of-type(1)").insertAdjacentHTML('beforebegin', `<li style="background-color: #DDEEE4;"><a href="\${gfgOptimizeNov23Url}" style="font-weight: bold;color: #121212 !important;">\${gfgOptimizeNov23HeaderSubHeaderText}</a></li>`):""; } else if((coursePromotionCities.GFG_CLASSROOM_PROGRAM_CITIES.NON_NCR).includes((userDemographicInfo.city_name).trim())) { gfgOptimizeNov23HeaderSubHeaderText = 'Classroom Programme'; gfgOptimizeNov23Url = 'https://www.geeksforgeeks.org/courses/category/all?courseType=offline&courseFeeType=all'; isElementInDOM('ul.header-main__list>li:nth-of-type(1) > ul.mega-dropdown > li:nth-of-type(1)')? (document.querySelector('ul.header-main__list>li:nth-of-type(1) > span').innerText.trim()=='Courses') ? document.querySelector('ul.header-main__list>li:nth-of-type(1) > ul.mega-dropdown > li:nth-of-type(1)').insertAdjacentHTML('beforebegin',`<li class="mega-dropdown__list-item" data-child="true" aria-expanded="false" data-expandable="false"><a href="\${gfgOptimizeNov23Url}" target="_self">\${gfgOptimizeNov23HeaderSubHeaderText}</a></li>`):"":""; isElementInDOM("#hslider>li:nth-of-type(1)")?document.querySelector("#hslider>li:nth-of-type(1)").insertAdjacentHTML('beforebegin', `<li style="background-color: #DDEEE4;"><a href="\${gfgOptimizeNov23Url}" style="font-weight: bold;color: #121212 !important;">\${gfgOptimizeNov23HeaderSubHeaderText}</a></li>`):""; } } else if((coursePromotionCities.MERN_CLASSROOM_PROGRAM_CITIES).includes((userDemographicInfo.city_name).trim())) // Header Subheader changes for city being Pune { gfgOptimizeNov23HeaderSubHeaderText = 'MERN Clasroom Program'; gfgOptimizeNov23Url = 'https://www.geeksforgeeks.org/courses/mern-full-stack-development-classroom?itm_source=geeksforgeeks&itm_medium=header&itm_campaign=courses'; isElementInDOM('ul.header-main__list>li:nth-of-type(1) > ul.mega-dropdown > li:nth-of-type(1)')? (document.querySelector('ul.header-main__list>li:nth-of-type(1) > span').innerText.trim()=='Courses') ? document.querySelector('ul.header-main__list>li:nth-of-type(1) > ul.mega-dropdown > li:nth-of-type(1)').insertAdjacentHTML('beforebegin',`<li class="mega-dropdown__list-item" data-child="true" aria-expanded="false" data-expandable="false"><a href="\${gfgOptimizeNov23Url}" target="_self">\${gfgOptimizeNov23HeaderSubHeaderText}</a></li>`):"":""; isElementInDOM("#hslider>li:nth-of-type(1)")?document.querySelector("#hslider>li:nth-of-type(1)").insertAdjacentHTML('beforebegin', `<li style="background-color: #DDEEE4;"><a href="\${gfgOptimizeNov23Url}" style="font-weight: bold;color: #121212 !important;">\${gfgOptimizeNov23HeaderSubHeaderText}</a></li>`):""; } else // Subheader Job-A-Thon 10 Nov 2023 optimization { if(isContest) { gfgOptimizeNov23HeaderSubHeaderText = 'Hiring Challenge Experienced'; gfgOptimizeNov23Url = 'https://practice.geeksforgeeks.org/contest/job-a-thon-25-hiring-challenge-for-experienced-professionals?itm_source=geeksforgeeks&itm_medium=sub_header&itm_campaign=contests'; isElementInDOM("#hslider>li:nth-of-type(1)")?document.querySelector("#hslider>li:nth-of-type(1)").insertAdjacentHTML('beforebegin', `<li style="background-color: #DDEEE4;"><a href="\${gfgOptimizeNov23Url}" style="font-weight: bold;color: #121212 !important;">\${gfgOptimizeNov23HeaderSubHeaderText}</a></li>`):""; } else if(dateToCheck <= optimizeNov23ContestFresherEndDate) { gfgOptimizeNov23HeaderSubHeaderText = 'Hiring Challenge Freshers'; gfgOptimizeNov23Url = 'https://practice.geeksforgeeks.org/contest/job-a-thon-26-hiring-challenge-for-freshers?itm_source=geeksforgeeks&itm_medium=sub_header&itm_campaign=contests'; isElementInDOM("#hslider>li:nth-of-type(1)")?document.querySelector("#hslider>li:nth-of-type(1)").insertAdjacentHTML('beforebegin', `<li style="background-color: #DDEEE4;"><a href="\${gfgOptimizeNov23Url}" style="font-weight: bold;color: #121212 !important;">\${gfgOptimizeNov23HeaderSubHeaderText}</a></li>`):""; } } } } function isElementInDOM(selector, all=false) { if(!all) { if(!document.querySelector(selector)) return false; else return true; } else { if(document.querySelectorAll(selector).length == 0) return false; else return true; } } ```