<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jingwen Xu</title>
    <description>The latest articles on DEV Community by Jingwen Xu (@jinglunaya).</description>
    <link>https://dev.to/jinglunaya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F570186%2Fa9b75397-90dd-40ba-85c4-cf4e41084655.jpeg</url>
      <title>DEV Community: Jingwen Xu</title>
      <link>https://dev.to/jinglunaya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jinglunaya"/>
    <language>en</language>
    <item>
      <title>Daily  learning log</title>
      <dc:creator>Jingwen Xu</dc:creator>
      <pubDate>Fri, 05 Feb 2021 15:44:24 +0000</pubDate>
      <link>https://dev.to/jinglunaya/daily-learning-log-ik7</link>
      <guid>https://dev.to/jinglunaya/daily-learning-log-ik7</guid>
      <description>&lt;h3&gt;
  
  
  basic JavaScript learning
&lt;/h3&gt;




&lt;h2&gt;
  
  
  Basic JavaScript: Shopping ListPassed
&lt;/h2&gt;

&lt;p&gt;Create a shopping list in the variable myList. The list should be a multi-dimensional array containing several sub-arrays.&lt;/p&gt;

&lt;p&gt;The first element in each sub-array should contain a string with the name of the item. The second element should be a number representing the quantity i.e.&lt;/p&gt;

&lt;p&gt;["Chocolate Bar", 15]&lt;/p&gt;

&lt;p&gt;There should be at least 5 sub-arrays in the list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var myList = [
    ["chocolate bar",15],
    ["yogurt",3],
    ["soya beans",1],
    ["pretzel",5],
    ["ananas",2],
];
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic JavaScript: Passing Values to Functions with ArgumentsPassed
&lt;/h2&gt;

&lt;p&gt;Parameters are variables that act as placeholders for the values that are to be input to a function when it is called. When a function is defined, it is typically defined along with one or more parameters. The actual values that are input (or "passed") into a function when it is called are known as arguments.&lt;/p&gt;

&lt;p&gt;Here is a function with two parameters, param1 and param2:&lt;/p&gt;

&lt;p&gt;function testFun(param1, param2) {&lt;br&gt;
  console.log(param1, param2);&lt;br&gt;
}&lt;br&gt;
Then we can call testFun: testFun("Hello", "World"); We have passed two arguments, "Hello" and "World". Inside the function, param1 will equal "Hello" and param2 will equal "World". Note that you could call testFun again with different arguments and the parameters would take on the value of the new arguments.&lt;/p&gt;

&lt;p&gt;Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console.&lt;br&gt;
Call the function with two numbers as arguments.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function functionWithArgs(a, b) {
    console.log(a + b)
}

functionWithArgs(1,2);
functionWithArgs(7,9);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic JavaScript: Stand in Line
&lt;/h2&gt;

&lt;p&gt;In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.&lt;/p&gt;

&lt;p&gt;Write a function nextInLine which takes an array (arr) and a number (item) as arguments.&lt;/p&gt;

&lt;p&gt;Add the number to the end of the array, then remove the first element of the array.&lt;/p&gt;

&lt;p&gt;The nextInLine function should then return the element that was removed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Setup
var testArr = [1,2,3,4,5];

// Display code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));

nextInLine([], 5);
nextInLine([], 1) ;
nextInLine(testArr, 10)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic JavaScript: Assignment with a Returned ValuePassed
&lt;/h2&gt;

&lt;p&gt;If you'll recall from our discussion of Storing Values with the Assignment Operator, everything to the right of the equal sign is resolved before the value is assigned. This means we can take the return value of a function and assign it to a variable.&lt;/p&gt;

&lt;p&gt;Assume we have pre-defined a function sum which adds two numbers together, then:&lt;/p&gt;

&lt;p&gt;ourSum = sum(5, 12);&lt;/p&gt;

&lt;p&gt;will call sum function, which returns a value of 17 and assigns it to ourSum variable.&lt;/p&gt;

&lt;p&gt;Call the processArg function with an argument of 7 and assign its return value to the variable processed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Setup
var processed = 0;

function processArg(num) {
  return (num + 3) / 5;
}

// Only change code below this line
processed = processArg(7);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>An easy way to understand Booleans</title>
      <dc:creator>Jingwen Xu</dc:creator>
      <pubDate>Fri, 05 Feb 2021 14:35:34 +0000</pubDate>
      <link>https://dev.to/jinglunaya/an-easy-way-to-understand-booleans-5257</link>
      <guid>https://dev.to/jinglunaya/an-easy-way-to-understand-booleans-5257</guid>
      <description>&lt;p&gt;Why true why false?&lt;br&gt;
Why 0 is false? &lt;/p&gt;

&lt;p&gt;Mainly just think as if it is valuable .&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let example1 = false;&lt;br&gt;
let example2 = true;&lt;br&gt;
let example3 = null;&lt;br&gt;
let example4 = undefined;&lt;br&gt;
let example5 = '';&lt;br&gt;
let example6 = NaN;&lt;br&gt;
let example7 = -5;&lt;br&gt;
let example8 = 0;)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;like &lt;/p&gt;

&lt;p&gt;0 doesn’t value any, so 0 is false, &lt;br&gt;
"" has nothing inside,(no value) that is why is is false.&lt;br&gt;
"  " with space, it  has something inside, and is a string, has value, so it is true.&lt;/p&gt;

&lt;p&gt;NaN not a number, doesn’t value any.&lt;br&gt;
-5 is value of -5. so it is valuable.&lt;/p&gt;

&lt;p&gt;At the beginning I was always use false as wrong, but it is mainly just by value, has value? or doesn’t value any.&lt;/p&gt;

&lt;p&gt;That's my understanding ...&lt;br&gt;
Hope this can help you as well.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
