Как мне написать эти методы jquery в псевдокоде? - PullRequest
0 голосов
/ 13 декабря 2018

Я изо всех сил пытаюсь понять, как я могу написать их с точки зрения псевдокода.

  function makeHeader(label, width){
      //make the header element
      newHeader = $("<th/> <br/>")
        .html(label)
        .addClass("col-sm-"+width)
      return newHeader
  }

Я имею в виду части .html и .addClass, я не совсем понимаю, как я могунапишите это в терминах псевдокода.

1 Ответ

0 голосов
/ 13 декабря 2018

Чтобы написать это:

function makeHeader(label, width){
    newHeader = $("<th/> <br/>").html(label).addClass("col-sm-"+width)
    return newHeader
}

В псевдокоде вы можете просто посмотреть на каждое утверждение и посмотреть, что оно делает, и, если вам нужна помощь, взглянуть на документацию jQuery .Но вот полный псевдокод:

Define a function makeHeader, which takes parameters label and width
    Define a variable newHeader, which is HTML markup <th></th><br/>.
        Set the innerHTML property of the element contained in newHeader to the label parameter passed to the function
        Add a class to the element contained in newHeader. The class added will be col-sm- followed by the width parameter passed to the function
    Return the newHeader variable from the function
...