Ahmed Elmalla - ICT IGCSE year 10 links - Your Dedicated Computer Science Tutor | Learn with Kemo
Ahmed Elmalla - Your Dedicated Computer Science Tutor | Learn with Kemo
IGCSE 0478 & A-level IB Computer Science Tutor AP Computer Science A Tutor A-level VB Tutor
Ahmed Elmalla - Your Dedicated Computer Science Tutor | Learn with Kemo

Blog

ICT IGCSE year 10 links

ICT IGCSE year 10 links

<script>

function animateValue(id, end, duration) {

  let obj = document.getElementById(id);

  let start = 0;

  let range = end - start;

  let increment = end > start ? 1 : -1;

  let stepTime = Math.abs(Math.floor(duration / range));

 

  let timer = setInterval(function() {

    start += increment;

    obj.textContent = start;

    if (start == end) clearInterval(timer);

  }, stepTime);

}

 

// Start animations

animateValue("count1", 200, 2000);

animateValue("count2", 7, 1500);

animateValue("count3", 14, 1500);

</script>

------------------

<script>

    const htmlToCheck = `

<div style="

  backgrou-color:#7ED321;

  color:white;

  text-align:enter;

  padding:40px 20px;

  font-family:Arial, sans-serif;

  display:flex;

  justify-content:space-around;

  flex-wrap:wrap;">

 

  <div style="margin:20px;">

    <h1 id="count1" style="font-size:40px; margin:0;">0</h1>

    <p style="font-size:20px; margin:5px 0;">Students Helped</p>

  </div>

 

  <div style="margin:20px;">

    <h1 id="count2" style="font-size:40px; margin:0;">0</h1>

    <p style="font-size:20px; margin:5px 0;">Expert Coaches</p>

  </div>

 

  <div style="margin:20px;">

    <h1 id="count3" style="font-size:40px; margin:0;">0</h1>

    <p style="font-size:20px; margin:5px 0;">Years Running</p>

  </div>

</div>

`;

 

// Basic dictionary of valid HTML tags

const validTags = [

  "div","h1","p","span","section","img","header","footer",

  "main","nav","ul","li","style","script","body","html"

];

 

// Basic dictionary of valid CSS properties

const validCSS = [

  "background-color","color","text-align","padding","margin",

  "font-family","display","justify-content","flex-wrap",

  "font-size","border","width","height","align-items"

];

 

function checkHTML(html) {

  console.log("\n🔍 Checking HTML block...\n");

 

  // Extract tags

  const tags = html.match(/<\/?([a-zA-Z0-9\-]+)/g) || [];

  tags.forEach(tag => {

    const clean = tag.replace(/<\/?/g, "").toLowerCase();

    if (!validTags.includes(clean)) {

      console.warn("❗ Possible invalid HTML tag:", clean);

    }

  });

 

  // Extract CSS from style="" blocks

  const styles = html.match(/style="([^"]*)"/g) || [];

  styles.forEach(styleBlock => {

    const stylesList = styleBlock

      .replace('style="', "")

      .replace('"',"")

      .split(";")

      .map(s => s.trim());

 

    stylesList.forEach(rule => {

      if (!rule) return; // skip empty

      const [prop] = rule.split(":");

      if (!validCSS.includes(prop.trim())) {

        console.warn("❗ Possible unknown CSS property:", prop.trim());

      }

    });

  });

 

  console.log("\n✔ HTML/CSS check complete.\n");

}

 

    // ---------------- SPELL CHECKER --------------------

const dictionary = [

  "function","let","const","var","if","else","return",

  "console","log","Math","abs","floor","setInterval",

  "document","getElementById","textContent","start",

  "end","duration","animateValue","Counter","Range",

  "Start","End"

];

    const studentCode = `

    function animateValue(id,end,duration) {

        let obj=documet.getElementById(id);

        let start=0;

        let range=end-start;

        let increment = end > start? 1:-1;

        let stepTime=Math.abs(Math.floor(duration/range));

 

        let timer=setInterval(function() {

            start += increment;

            obj.textCotent = start;

            if(start == end) clearInterval(timer);

        },stepTime);

    }

 

    //Start animations

    animateValue("count1",20,2000);

    animateValue("count2",7,1500);

    animateValue("count3",14,1500);

`;

 

// SPELLING CHECKER LOGIC

function checkSpelling(text) {

    const words = text

      .replace(/[^a-zA-Z]/g, " ")

      .split(/\s+/)

      .filter(w => w.length > 2);

 

    const unknownWords = [];

 

    words.forEach(word => {

        if (!dictionary.includes(word)) {

            unknownWords.push(word);

        }

    });

 

    console.log("❗ Possible spelling mistakes or unknown words:");

    console.log([...new Set(unknownWords)]);

}

console.log(checkSpelling(studentCode));

checkHTML(htmlToCheck);

 

</script>