From 07ca137e786da16f70ac4ead9787abbb8da652a8 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 13 Dec 2022 21:44:14 +0800 Subject: [PATCH] Update JavaScript code to docs style (Chapter of Tree) --- codes/javascript/include/TreeNode.js | 6 +++--- docs/chapter_tree/binary_tree.md | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/codes/javascript/include/TreeNode.js b/codes/javascript/include/TreeNode.js index 20c709e96..6add12f0c 100644 --- a/codes/javascript/include/TreeNode.js +++ b/codes/javascript/include/TreeNode.js @@ -8,9 +8,9 @@ * Definition for a binary tree node. */ function TreeNode(val, left, right) { - this.val = (val === undefined ? 0 : val) // 结点值 - this.left = (left === undefined ? null : left) // 左子结点指针 - this.right = (right === undefined ? null : right) // 右子结点指针 + this.val = (val === undefined ? 0 : val); // 结点值 + this.left = (left === undefined ? null : left); // 左子结点指针 + this.right = (right === undefined ? null : right); // 右子结点指针 } /** diff --git a/docs/chapter_tree/binary_tree.md b/docs/chapter_tree/binary_tree.md index 5913a1a43..84270be01 100644 --- a/docs/chapter_tree/binary_tree.md +++ b/docs/chapter_tree/binary_tree.md @@ -65,9 +65,9 @@ comments: true ```js title="" /* 链表结点类 */ function TreeNode(val, left, right) { - this.val = (val === undefined ? 0 : val) // 结点值 - this.left = (left === undefined ? null : left) // 左子结点指针 - this.right = (right === undefined ? null : right) // 右子结点指针 + this.val = (val === undefined ? 0 : val); // 结点值 + this.left = (left === undefined ? null : left); // 左子结点指针 + this.right = (right === undefined ? null : right); // 右子结点指针 } ``` @@ -201,10 +201,10 @@ comments: true /* 初始化二叉树 */ // 初始化结点 let n1 = new TreeNode(1), - n2 = new TreeNode(2), - n3 = new TreeNode(3), - n4 = new TreeNode(4), - n5 = new TreeNode(5); + n2 = new TreeNode(2), + n3 = new TreeNode(3), + n4 = new TreeNode(4), + n5 = new TreeNode(5); // 构建引用指向(即指针) n1.left = n2; n1.right = n3;