Giter Site home page Giter Site logo

quizcomponentgenerator's Introduction

What is quizComponentGenerator?

"quizComponentGenerator" is a function of Javascript(ES6).

This function returns nothing. But instead of it, it generates html tags inside of the function like this,

<div class="question-container">
  <div class="question-desc">
  ...(input text)
  </div>

  <div class="output-container">
    <p class="output-title">OUTPUT</p>
    <p class="output-text">
    ...(output text)
    </p>
  </div>
</div>

Using this, you can show the inputs & outputs of many exercises you wrote in JS files efficiently on the browser.

Here is a sample how the browser looks like.

sample

What this function looks like?

The following is "quizComponentGenerator" itself.

// Generate a component for the excercise
function quizComponentGenerator(inputText,outputText){

  // create 'div' with a class name for the Question-Text
  let div = document.createElement('div');
  div.setAttribute("class", "question-container");

  // create 'div' with a class name
  let divQueationText = document.createElement('div');
  divQueationText.setAttribute("class", "question-desc");
  divQueationText.innerHTML = inputText;

  //append a child
  div.appendChild(divQueationText);

  // create 'div' with a class name for the output
  let divOutput = document.createElement('div');
  divOutput.setAttribute("class", "output-container");
  div.appendChild(divOutput);

  let p_title = document.createElement('p');
  p_title.setAttribute("class", "output-title");
  p_title.innerHTML = "OUTPUT";
  let p_output = document.createElement('p');
  p_output.setAttribute("class", "output-text");
  p_output.innerHTML = outputText;

  divOutput.appendChild(p_title);
  divOutput.appendChild(p_output);

  document.body.appendChild(div);

}

How to use it?

This function requires two arguments(parameters) which are inputText and outputText.

function quizComponentGenerator(inputText,outputText){...}

inputText is supposed to be used for inputting a sentence of the quiz as String.

outputText is supposed to be used for outputting the answer you want to show. and it also needs to be String.

quizcomponentgenerator's People

Stargazers

Kaai Suzuki avatar

Watchers

James Cloos avatar Kitayama Noriaki avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.